GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Add 'Suggestion' diagnostics · Pull Request #22204 · microsoft/TypeScript ConversationFixes #19392 Previously we had just syntax and semantic diagnostics. This adds a third layer of "info" diagnostics. They are only a part of services, so do not impact command line compilation. Now when the editor sends us a "geterr" request, we will send 3 responses for "syntaxDiag", "semanticDiag", and "infoDiag". (See changes to For use from Visual Studio, this also adds a "infoDiagnosticsSync" command. (Andrew Casey (@amcasey) or would it be easier to just send it along with "semanticDiagnosticsSync"? Might impact performance as we add more info diagnostics though.) For now there is only one info diagnostic, for a file that could be converted to commonJs. Moved the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
ghost
requested review from
Andrew Casey (amcasey) and
Sheetal Nandi (sheetalkamat)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would call it
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||
| /** | ||
| * The category of the diagnostic message, e.g. "error" vs. "warning" | ||
| * The category of the diagnostic message. This is the lower-case of a DiagnosticCategory member. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
the generated protocol.d.ts does not have DiagnosticCategory. so I would keep the comment in there.
One other thing also is we allow extensions to set it, so it is possible that there are other values here. so a union of string literals would be too restrictive for clients.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (diags) { | ||
| const bakedDiags = diags.map((diag) => formatDiag(file, project, diag)); | ||
| this.event<protocol.DiagnosticEventBody>({ file, diagnostics: bakedDiags }, "syntaxDiag"); | ||
| // TODO: why do we check for diagnostics existence here, but in semanticCheck send unconditionally? |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
we should report both unconditionally
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -0,0 +1,8 @@ | |||
| /* @internal */ | |||
| namespace ts { | |||
| export function infoDiagnostics(sourceFile: SourceFile): Diagnostic[] { | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
consider naming it compute*Diagnostics
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Just a few comments about the name of the enum value. Andrew Casey (@amcasey) any comments? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
With the enum name change
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| export enum DiagnosticCategory { | ||
| Warning, | ||
| Error, | ||
| Info, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This isn't quite what Roslyn calls Info, so I'm fine with either Info or Suggestion (or Hint, which appears to be the VS Code name).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| arguments: InfoDiagnosticsSyncRequestArgs; | ||
| } | ||
|
|
||
| export interface InfoDiagnosticsSyncRequestArgs extends FileRequestArgs { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can/should interface declarations be shared across the various kinds of diagnostics?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (diags) { | ||
| const bakedDiags = diags.map((diag) => formatDiag(file, project, diag)); | ||
| this.event<protocol.DiagnosticEventBody>({ file, diagnostics: bakedDiags }, "syntaxDiag"); | ||
| // TODO: why do we check for diagnostics existence here, but in semanticCheck send unconditionally? |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const errorCodes = [Diagnostics.File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module.code]; | ||
| registerCodeFix({ | ||
| errorCodes, | ||
| getCodeActions(context) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This seems much simpler. 😄
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| verify.completionListContains("eggs"); | ||
| edit.insert("eggs;"); | ||
| verify.noErrors(); | ||
| verify.noErrors({ ignoreInfoDiagnostics: true }); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Personally, I would expect noDiagnostics to mean "no diagnostics of any severity" and noErrors to mean "no diagnostics of error severity".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm going to try hacking up my local VS build to confirm that I can consume this. I don't expect issues. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I've created an internal PR that makes VS consume the new API. LGTM |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Andrew Casey (@amcasey) Mohamed Hegazy (@mhegazy) good to go? (Note that since name has changed to "suggestion", VS will need to change too.) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm fine with either "Info" or "Suggestion" and I've already confirmed that I can consume the new API from VS. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
codeFixes for things that aren't diagnostics
There was an error while loading. Please reload this page.