microsoft / microsoft/TypeScript

Type Selection Queries

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

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

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

説明

This might be a bit of a crazy idea, but here goes: to enable loose coupling between components we sometimes write Pick<Type, 'a' | 'b' | 'c'>

It would be nice if we could create a type query to select properties with a similar syntax to GraphQL:

e.g:

prop: AType[{a, b, c: { d }]

This would be equivalent to

prop: Pick<AType, 'a' | 'b'> & {c: Pick<AType['c'], 'd'>}

How often would you do that in "the real world" ? definitely more often if you could
How often should you do that? unclear ?

Some real-world code:

    const testFetch = jest.fn()

    class TestOptions extends GraphQlClient.Options {
      public fetch = testFetch
    }
    const response: Pick<Response, 'ok' | 'json'> = {
      ok: true,
      async json() {
        return { data: { auth: { token: testToken } } }
      }
    }
    testFetch.mockResolvedValue(response)

Pick<Response, 'ok' | 'json'> could be Response[{ok, json}]

edit: that's not a great example use case, cause you could just as well do Partial<Response>

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

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

はじめの一歩

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

調査の方向性

まず、TypeScript における既存の Pick と indexed-access type の挙動を調査し、次に提案されているネストされた選択構文を GraphQL 形式のクエリと比較します。issue の例を確認し、この機能に明確なユースケースと型システムの設計があるかどうかを判断します。完了とするには、単なる変換例ではなく、合意された構文、セマンティクス、実装計画が必要です。

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

評価

技術スタック
typescript
領域
compilers
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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