microsoft / microsoft/TypeScript

Display signature help or completions for tuples with labels

オープン
#53,197 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Experience Enhancement Help Wanted Suggestion
主要言語
Go
スター
111k
フォーク
14.4k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

Suggestion

🔍 Search Terms

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

✅ Viability 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, new syntax sugar for JS, etc.)
  • [x This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

📃 Motivating Example

declare const coords: [x: number, y: number]

const [/**/] = coords

The problem: having no idea what a name to type as you don't know what the type of it.

I'm using it with my plugin and it looks very simple (and useful IMO):

Of course, you can hover of the variable to fiture it out, but what about the following example:

const a: {
    coords: [x: number, y: number] | string | { x: number; y: number }/* | even more types */
} = {
    coords: [/**/], // the type with x, y tuples can be even truncated, so you can only guess names of labels
}

I understand that labeled tuples introduced in ts4.0 were designed primarily for parameters usage, but I've seen them used for shorter static data declarations as well.

However, if you think that usage signature help is redundant and incorrect, what about having completions for tuple labels at least? There is already completions when acessing such symbols via dot property access. For example for first example it would be keyword completion with label x and [0]: number detail.

💻 Use Cases

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず labeled-tuple の例と、提案されている2つの動作、つまり tuple の分割代入中の signature help と tuple labels の completions を確認します。どの動作をサポートすべきか、また unions や truncated tuple types に対してどのように動作すべきかを定義し、その後、関連する TypeScript language-service の entry points とテストを特定します。選択したインタラクションによって有用な label 情報が提供され、runtime output が変更されなければ完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
developer-experience
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。