microsoft / microsoft/TypeScript
language service suggestion for Declare property '...' in constructor argument
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
Search Terms
- typescript declare property in constructor
- typescript language service declare property in constructor
Suggestion
When a non-existing property x is accessed on this in a class method, one of the fixes that ts language service currently suggests, is:
Declare property x
Which adds property x to the class.
It would be nice to also have Declare property x in constructor arguments.
It can use private access modifier by default.
Use Cases
While it's generally useful, it becomes especially handy when developing applications with DI frameworks like Angular that use constructor injection to wire dependencies together.
Examples
-
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript / JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. new expression-level syntax)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
既存の TypeScript language-service の「Declare property x」提案から始め、その code-fix のエントリーポイントとテスト(存在する場合)を追跡します。constructor arguments で x を宣言し、private をデフォルトの修飾子とする要求された代替案を追加し、説明されている class-method のケースと生成される結果で提案を検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100