microsoft / microsoft/TypeScript

Detect Typescript in Javascript editors opened and inform developer, that he is writing different syntax and it will silently fail (probably)

Aperta
#60,428 1 commento 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Needs More Info
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

It would be super helpful to have something like:

Warning: TypeScript syntax detected in .jsx file. 
Would you like to:
[ ] Rename to .tsx
[ ] Remove TypeScript syntax
[ ] Ignore warning

This kind of UX improvement could save developers (especially those transitioning between JS and TS projects) a lot of time and frustration. It seems like a relatively straightforward detection that could help a lot of people!

VSCode already does similar helpful suggestions for other cases (like offering to create files that don't exist when you import them), so this would fit right in with that philosophy.

What it would solve?

It's the classic .jsx vs .tsx gotcha! 😄

This is such a common issue that even experienced developers run into it regularly. The file extension makes all the difference because:

  • .jsx files are treated as regular JavaScript/React files
  • .tsx files are treated as TypeScript/React files

So TypeScript typing just "silently fails" to work in .jsx files without any obvious error message about why the types aren't working.

It's one of those "spend an hour debugging only to realize it's a file extension" moments that every developer has experienced!

  • .CJS -> .TS, .JS -> .TS, .JSX -> .TSX

(Similar functionality could be created for CSS -> SCSS, ... .)

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

L’issue non indica file, test o punti di ingresso. Inizia individuando dove sono implementati i diagnostici dell’editor o i suggerimenti del language service, quindi determina come si integrerebbero il rilevamento della sintassi e le azioni di rinomina, rimozione o ignoramento; il lavoro è completato quando l’avviso proposto funziona per le estensioni elencate senza alterare il JavaScript valido.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, typescript
Ambito
developer-experience, tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.