microsoft / microsoft/TypeScript
Refactor/codefix: find missing variable in destructured object
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
Search Terms
refactor
codefix
auto import
destructuring
parameter
Suggestion
There is a feature in VSCode today where you can type the name of a function and the editor suggests automatically importing that function, which is very useful.

It would be useful to have a similar feature for finding variables in objects that have been destructured, for example in the props parameters of react functions. It should be possible for typescript to find out that a variable is available in a destructured object in the current closure, for example:

In the above example the first option should suggest to add name to the destructuring of Props in the parameters of the function, since there is a name: string as part of Props.
Use Cases
Using destructuring is very common in for example functional react components. The props object can grow very large and it is annoying and repetitive to type out the name of all the destructured properties.
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. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue ではファイル、テスト、エントリポイントが指定されていません。まず、欠落した名前に対する TypeScript language-service codefixes と destructured parameters の処理を見つけ、次に提案された動作を既存の auto-import suggestions と比較します。完了条件は、欠落している変数について、現在の destructuring pattern に対応する property を追加する提案ができ、説明された例に対するカバレッジがあることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- developer-experience, tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 28/100