microsoft / microsoft/TypeScript
Ability to disable TS8010: 'types' can only be used in a .ts file.
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
Search Terms
TS8010
TS 8010
types can only be used in a .ts file
'types' can only be used in a .ts file
Suggestion
Ability to disable TS8010: 'types' can only be used in a .ts file. Type annotations could simply be ignore by tsc when compiling a .js file.
Use Cases
I work in a JS / TS blended codebase. My team uses WebStorm as our IDE, and it supports type annotations in .js files. When a variable/param is typed, it provides type-specific autocompletion. As you can imagine, that's quite powerful when working in a JS environment. Consequently, we have thousands of type annotations throughout our JS files. We would like to add allowJs:true to our tsconfig.json, however tsc throws an error for every type annotation in each JS file.
Checklist
My suggestion meets these guidelines:
- [ x ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [ x ] This wouldn't change the runtime behavior of existing JavaScript code
- [ x ] This could be implemented without emitting different JS based on the types of the expressions
- [ x ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- [ x ] This feature would agree with the rest of TypeScript's Design Goals.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Diagnose TS8010 und der Option allowJs in tsconfig.json und verfolge dann, wie tsc Typannotationen in .js-Dateien meldet. Die Aufgabe ist abgeschlossen, wenn eine Konfiguration diese Diagnose deaktivieren kann, ohne das Verhalten des erzeugten JavaScript zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100