[typescript] Coloring is broken for type assertion functions with multi-line generic return types
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.137.0-1
- OS Version: Arch, online
Steps to Reproduce:
1. Open a file with TS syntax and coloring
2. Copy and paste:
```ts
type A = {
a?: number;
};
class Test {
hereColoringIsOk() {
const x = 123;
return x;
}
thisMethodBreaksColoring(r: A): r is
Required {
return 'a' in r && !!r.a;
}
nowColoringIsBroken() {
const x = 123;
return x;
}
}
```
The issue triggers at the type assertion return type being multi-line. If the typing is a single line, the rest of the code is colored as expected. I found this problem while using Prettier and having longer type names, which forces the code to be multi-line with union types.
I managed to replicate the issue in vscode.dev, stackblitz.com, and local VS Code.
StackBlitz:
vscode.dev:
Local:
#### Things I figured while creating the reproduction:
- The return type MUST be generic:
- Strings inside the type assertion are breaking the coloring outside of the scope:
- The original code that caused my issue:
A "fix" to my issue is not using the Partial type at the end:
Contributor guide
Assessment
This issue has not been assessed yet.