microsoft / microsoft/TypeScript
Change Diagnostic.code to 'string | number'
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Diagnostic type and the LanguageService plugin API, then compare the current numeric code requirement with the Language Server Protocol definition mentioned in the issue. Check how diagnostic codes are consumed and displayed, and consider existing numeric diagnostics before determining whether string codes can be accepted without breaking current behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100