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 — Introduce related spans into tsserver protocol by weswigham · Pull Request #24548 · microsoft/TypeScript Conversation
|
| file: SourceFile | undefined; | ||
| start: number | undefined; | ||
| length: number | undefined; | ||
| messageText: string | DiagnosticMessageChain; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
messageText: string | DiagnosticMessageChain; [](start = 8, length = 45)
I think I need more information about how these are intended to be used. Roslyn diagnostics support additional locations, but those locations don't have messages. We could create separate diagnostics but we would need a new code and category and I don't believe we'd be able to link them together. I think Roslyn more or less dropped this functionality (vs the old native compiler).
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.
Secondary code locations and more information pertaining to specifically that location in the context of the diagnostic. (eg, "Defined here", "Declared here", "Replicated here", and so on. The additional spans also allow us to use those spans when calculating quick fixes - so we can, for example, know what we can suggest a cast at the site of an assignability error, but also suggest modifying the type the assignment is failing against (because it is mentioned as a related span). The only diagnostic set we currently do a similar thing with is the esModuleInterop import error, which we currently issue a secondary diagnostic for (so there's no obvious link between the two).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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.
For reference, this isn't a new concept and there is prior art, which is why vscode has basic support for them (and is looking to iterate on their UI) - rust makes good use of related spans in it's errors.
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.
I'm not saying that it's either novel or bad, just that it goes against the grain of the API we're using.
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.
We need to sit down and design this feature.. there seems to be two uses cases,
x is not assignable to string, and here is where x was declated
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| function createDiagnostic(start: protocol.Location, end: protocol.Location, message: DiagnosticMessage, args: ReadonlyArray<string> = [], category = diagnosticCategoryName(message), reportsUnnecessary?: {}): protocol.Diagnostic { | ||
| return { start, end, text: formatStringFromArgs(message.message, args), code: message.code, category, reportsUnnecessary, source: undefined }; | ||
| function createDiagnostic(start: protocol.Location, end: protocol.Location, message: DiagnosticMessage, args: ReadonlyArray<string> = [], category = diagnosticCategoryName(message), reportsUnnecessary?: {}, relatedInformation?: protocol.DiagnosticRelatedInformation[]): protocol.Diagnostic { | ||
| return { start, end, text: formatStringFromArgs(message.message, args), code: message.code, category, reportsUnnecessary, relatedInformation, source: undefined }; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
relatedInformation [](start = 130, length = 18)
Should this new property be validated in some way?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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.
Nothing has been modified to produce one yet, though we have a massive list courtesy of Daniel Rosenwasser (@DanielRosenwasser) - this just makes it so we can start chipping that list away.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| relatedInformation: map(diag.relatedInformation, formatRelatedInformation), | ||
| }; | ||
| return includeFileName | ||
| ? { ...common, fileName: diag.file && diag.file.fileName } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
no need to create an object just to inline it.. you can set fileName to undefined
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Wesley Wigham (@weswigham) we should also show the additional locations under |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
a51811c to
fb03d91
Compare
|
Mohamed Hegazy (@mhegazy) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Mohamed Hegazy (@mhegazy) I've implemented the pretty output (as above) as well as the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Daniel Rosenwasser (@DanielRosenwasser) Wanna open your massive list of error-updating backlog issues now that this is in? |
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.
There was an error while loading. Please reload this page.