microsoft / microsoft/TypeScript
Suggestion: Allow Types in JS Files
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
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
Inizia esaminando l’implementazione proposta nel commit 57a69d880251088d550500dcb018fc4e53895916 e gli esempi in questa issue. Determina in che modo l’opzione del compilatore dovrebbe influire sul JavaScript tipizzato, quindi aggiungi test che coprano le dichiarazioni mostrate e conferma che vengano compilate quando l’opzione è abilitata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, typescript
- Ambito
- compilers
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100