microsoft / microsoft/TypeScript
Better intellisense for unions of tuple types
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
VSCode - Version 1.45.1
Typescript - Version 3.8.3
Search Terms
intellisense tuple
Suggestion
Have the suggestions of unions of tuple types only suggest valid things
Use Cases
I have a function which takes a 'path' to a property in a fixed object, say the object is like { a: { b: 1 } }, allowed paths are ["a"], or ["a", "b"].
I have some type which generates for me the union of allowed tuples, which is to be the type of the 'path'.
The fixed object the function takes paths in is very large and I don't want to have to remember the names of things, when I use the union, the intellisense correctly identifies if a path is invalid, but when using ctrl + space to get the suggestions, it suggests strings which if used are immediately afterwards recognised as invalid.
Examples
Consider a type like
type X = ["A"] | ["A", "B"]
Then if I write something like const x: X = [], when pressing ctrl + space in the array I would like to just be suggested "A" (in fact this is already the behaviour), after filling in "A", if I try to add another element it would just suggest "B", not "A", "B"
Checklist
My suggestion meets these guidelines:
- [x ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [x ] This wouldn't change the runtime behavior of existing JavaScript code
- [x ] This could be implemented without emitting different JS based on the types of the expressions
- [x ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- [x ] This feature would agree with the rest of TypeScript's Design Goals.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
実装ファイルもテストも指定されていません。指定された TypeScript バージョンで VS Code 上の tuple-union の例を再現し、その後で関係する completion entry point を特定してください。完了条件は、"A" を含む配列の次の要素に対して "B" だけが候補として提示され、既存の妥当性チェックが維持されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- developer-experience
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100