You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change Diagnostic.code to 'string | number' #28911
I'm writing a LanguageService plugin for TypeScript that returns custom diagnostics. A Diagnostic needs to have a code property of type number.
I don't have a number. Instead I can provide a string that represents the name of the rule producing the diagnostic. In addition a random number I would choose looks quite ugly in the tooltip VSCode displays for the Diagnostic.
I know TypeScript only ever creates Diagnostics with numeric code, but it's too limiting for plugins.
I looked it up and the LanguageServer protocol specifies it as code?: number | string.
My current workaround is to use a type assertion. Until now nothing bad has happened.
Reacted by Wesley Wigham, S. B. Tam and Josh Ghoulberg 👻
Daniel Rosenwasser (@DanielRosenwasser) I wholeheartedly agree with this - I've made it twice in PRs we never merged about extensibility - it just makes a lot of sense for diagnostics that aren't from us.
it might be better to return a new property on Diagnostic objects.
Does this only affect Diagnostic (DiagnosticRelatedInformation to be precise) or should it also be added to DiagnosticMessageChain and/or DiagnosticMessage?
Does this require a change to the LanguageServerProtocol spec?
Activity
weswigham commentedon Dec 7, 2018
Daniel Rosenwasser (@DanielRosenwasser) I wholeheartedly agree with this - I've made it twice in PRs we never merged about extensibility - it just makes a lot of sense for diagnostics that aren't from us.
DanielRosenwasser commentedon Dec 10, 2018
Seems pretty reasonable to me.
ajafff commentedon Dec 14, 2018
Continuing discussion from #28959
Does this only affect
Diagnostic(DiagnosticRelatedInformation to be precise) or should it also be added toDiagnosticMessageChainand/orDiagnosticMessage?Does this require a change to the LanguageServerProtocol spec?