microsoft / microsoft/TypeScript-TmLanguage
Messed syntax highlighting
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 471
- Forks
- 149
- PR merge metrics
- No merged PRs in 30d
Description
Does this issue occur when all extensions are disabled? ✔️
- VS Code Version: 1.56.2
- OS Version: Windows 10
- Language: TypeScript
Description:
- When a type declaration statement without an ending semicolon is followed directly by some specific statement, like a function call, the syntax highlighting of the following codes becomes messed up. If we add a semicolon at the end, or a blank line, the syntax highlighting will return to normal. Though this bug could be easily avoided by users, I still recommend it be fixed, since syntax highlighting should always synchronize with compilers, and such codes can be successfully compiled by tsc.
How to Reproduce:
- Copy the following snippet into VS Code
async function foo(): Promise<number> { return Promise.resolve(0); } type Type = string foo().then(async bar => { if (typeof (bar) == "number") console.log("number"); const year = 2021; }); - Check out the syntax highlighting, it should be something like the following image:

Contributor guide
No contributing guide indexed for this repository
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 reproducing the reported snippet in VS Code 1.56.2 with extensions disabled and compare highlighting with and without the semicolon or blank line. The payload names no source file or test; done means the TypeScript grammar keeps the following code highlighted correctly when the declaration has no semicolon.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100