Open ajafff opened 5 years ago
@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.
Seems pretty reasonable to me.
Continuing discussion from #28959
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?
I'm writing a LanguageService plugin for TypeScript that returns custom diagnostics. A
Diagnostic
needs to have acode
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 ascode?: number | string
.My current workaround is to use a type assertion. Until now nothing bad has happened.