microsoft / microsoft/TypeScript-TmLanguage
Code Highlighting Broken for Generic Functions with Default Values in .tsx Files
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 471
- Fork
- 149
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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:
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci l'esempio in un file .tsx e confrontane l'evidenziazione con quella dello stesso codice in un file .ts. Esamina le regole della grammatica TextMate di TypeScript per i parametri generici con valori predefiniti e le funzioni freccia; il lavoro è completato quando i colori di .tsx corrispondono all'evidenziazione TypeScript prevista senza influire sul comportamento esistente di .ts.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100