microsoft / microsoft/TypeScript-TmLanguage
Bad syntax Highlighting in TS when using multiline union types
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?: Yes/No
- VS Code Version: 1.95.3
- OS Version: MacOS 15.0.1
Steps to Reproduce:
Write the following in VSCode
let myObj:
| {
prop1: string
}
| {
prop2: string
}
function myFunc() {}
The syntax of function myFunc() {} and everything after it is broken.
I found that it happens only in this rare edge case. Some things that actually fix it:
- Adding a semicolon
let myObj:
| {
prop1: string
}
| {
prop2: string
};
function myFunc() {}
- Writing the union type on a single line
let myObj: { prop1: string } | { prop2: string }
function myFunc() {}
- Adding a line break before the next line of code
let myObj:
| {
prop1: string
}
| {
prop2: string
}
function myFunc() {}
Bad highlighting:
Wanted highlighting:
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
Reproduce the TypeScript snippet in VS Code and inspect the repository's TextMate grammar files to locate handling for multiline union types. Done means the following function is highlighted correctly without requiring a semicolon or an extra blank line.
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