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

Offen
#60,428 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
30/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Veraltet

Rechercherichtung

Das Issue nennt keine Dateien, Tests oder Einstiegspunkte. Beginne damit zu ermitteln, wo Editor-Diagnosen oder Vorschläge des Language Service implementiert sind, und bestimme dann, wie Syntaxerkennung und Umbenennungs-, Entfernungs- oder Ignorieraktionen hineinpassen würden; als abgeschlossen gilt die vorgeschlagene Warnung, wenn sie für die aufgeführten Erweiterungen funktioniert, ohne gültiges JavaScript zu beeinträchtigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Needs More Info

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, ... .)

Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoft/TypeScript

Alle Issues in microsoft/TypeScript

Ähnliche Issues

Weitere Issues zu Go

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.