microsoft / microsoft/TypeScript

Eliminate non-generic functions

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

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

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

説明

Every non-generic function can be expressed as generic function with a single type parameter corresponding to each argument. Explicit parameter type annotations simply correspond to extends constraints on the type parameters of the generic equivalent.

While the title of the issue is "eliminate non-generic functions", in practice this simply gets rid of all the syntax ceremony involved in declaring generic functions. A function declaration as follows:

function repeat(item, n: number) => Array(n).fill(item)

will be inferred as: type F = <T1 extends any, T2 extends number>(item: T1, number: T2) => T1[], and the result of invoking it with repeat("foo", 10) is inferred as string[], not any[].

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

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

はじめの一歩

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

調査の方向性

ファイル、テスト、エントリポイントは指定されていません。まず、issue で提案されている推論の例と、その周辺にある TypeScript の型推論設計を調査してください。通常の関数宣言から、明示的なジェネリック構文なしでジェネリックパラメーターと制約を推論する実装について合意できれば完了です。

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

評価

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

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

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