microsoft / microsoft/TypeScript
Suggestion: Allow Types in JS Files
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
I have a large Angular2 project written in JavaScript, in which we use transform-flow-strip-types in order to allow Angular2 dependency injection to work from JavaScript.
This is currently an error in a JavaScript file compiled with tsc:
class MyClass {
prop:string; //err: 'types' can only be used in a .ts file
constructor(x: string) { //err: 'types' can only be used in a .ts file
}
someMethod():string { //err: 'types' can only be used in a .ts file
}
}
I would like an allowTypesInJsFiles compiler option which would allow us to compile JavaScript files which contain types. All of the above errors would be valid if the flag is set. This would allow us to use Angular2 DI from JavaScript files.
I have a branch with a simple implementation which I have verified to work.
Is this a change which could be accepted? If so I will add tests and sign the CLA.
I think it would be very useful for people migrating large JavaScript projects to TypeScript.
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 Überprüfung der vorgeschlagenen Implementierung im Commit 57a69d880251088d550500dcb018fc4e53895916 und der Beispiele in diesem Issue. Ermittle, wie sich die Compileroption auf typisiertes JavaScript auswirken sollte, füge anschließend Tests hinzu, die die gezeigten Deklarationen abdecken, und bestätige, dass sie kompiliert werden, wenn die Option aktiviert ist.
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