microsoft / microsoft/TypeScript
Suggestion: Allow Types in JS Files
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、コミット 57a69d880251088d550500dcb018fc4e53895916 の提案された実装と、この issue の例を確認します。コンパイラオプションが型付き JavaScript にどのような影響を与えるべきかを判断し、示されている宣言を対象とするテストを追加して、そのオプションを有効にしたときにコンパイルされることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100