Code Highlighting Broken for Generic Functions with Default Values in .tsx Files
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- tooling
Research direction
Reproduce the example in a .tsx file and compare its highlighting with the same code in a .ts file. Inspect the TypeScript TextMate grammar rules for generic parameters with default values and arrow functions; done means the .tsx colors match the expected TypeScript highlighting without affecting the existing .ts behavior.
Written by the indexing model from the issue text.
Description
Does this issue occur when all extensions are disabled?: Yes
- Version: 1.95.0-insider
- Commit: 804f450ca900d24db25e7174e8b6dfb3fb2a318c
- Date: 2024-10-22T13:30:10.100Z
- Electron: 32.2.1
- ElectronBuildId: 10427718
- Chromium: 128.0.6613.186
- Node.js: 20.18.0
- V8: 12.8.374.38-electron.0
- OS: Darwin x64 24.0.0
Describe the bug
In VSCode, when writing a generic function with default values in a .tsx file, code highlighting is broken and colors are displayed incorrectly. The same code works fine in a .ts file.
To Reproduce
- Open VSCode and create a new
.tsxfile. - Write the following code:
const func = <T = string,>(args: T): string => {
const t = typeof args;
if (typeof t === 'string') {
return t.split(',').join('_');
}
return '';
};
func('');
const add = (a: number, b: number) => {
return a + b;
};
- Observe the code highlighting.
Expected behavior
Code highlighting should work correctly and match the behavior in .ts files.
Screenshots
In .tsx file:
Pay attention to the screenshot where the generic default parameter definitions, colons, and arrow function arrows are all highlighted in red, while the colors of keywords such as const, if, and return are incorrect.
In .ts file:
- Dominant language
- TypeScript
- Stars
- 471
- Forks
- 149
- PR merge metrics
- No merged PRs in 30d
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.
More from microsoft/TypeScript-TmLanguage
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
microsoft/TypeScript-TmLanguage#1071 ·
-
triste Open
Difficulty 5/5 Over a week Newbie friendliness 5/100
microsoft/TypeScript-TmLanguage#1078 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
microsoft/TypeScript-TmLanguage#1076 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 55/100
microsoft/TypeScript-TmLanguage#1074 · 2 comments ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 58/100
microsoft/TypeScript-TmLanguage#1066 · 1 comment ·
All issues in microsoft/TypeScript-TmLanguage
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug v2
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
modelcontextprotocol/inspector#2458 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
railmapgen/rmp-gallery#4068 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
carbon-design-system/ibm-products#9907 ·