microsoft / microsoft/TypeScript

Intellisense does not work with [P in keyof T]

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

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

Experience Enhancement Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

TypeScript Version: 2.1.5

Code

//Operators available for the object fields
export type Operators<T> = {
    $elementMatch?: T | Operators<T>;
    $in?: T[];
}

//Filter declaration. 
export type Filter<T> = {
    //field, you can assign a value, or an operator.
    [P in keyof T]: Operators<T[P]> | T[P];
}

function query<T>(filter: Filter<T>) {  }

//Sample class
class Sample {
    foo: string;
    bar: number;
}

query<Sample>({
    //We want to put on the "foo" operator "$in"
    value: {
        //Intellisense then no output
    }
});



Expected behavior:
Intellisense should display all available options.
For example:
$elementMatch
$in

Actual behavior:
Intellisense does not offer anything.
If the "[P in key of T]" is replaced by "[key: string]", then the Intellisense for operators begins to work, but in this case we lose the test fields.

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

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

はじめの一歩

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

調査の方向性

Operators、Filter、query を使用した TypeScript 2.1.5 のサンプルで IntelliSense の失敗を再現します。まず、マップ型 [P in keyof T] の補完処理を追跡します。$elementMatch$in のオプションが、マップされたフィールドのチェックを失うことなく演算子オブジェクト内に表示されれば完了です。

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

評価

技術スタック
typescript
領域
developer-experience
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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