microsoft / microsoft/TypeScript
Allow "T extends enum" generic constraint
オープン
まだ誰も着手していません。
Awaiting More Feedback
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript has a discrete enum type that allows various compile-time checks and constraints to be enforced when using such types. It would be extremely useful to allow generic constraints to be limited to enum types - currently the only way to do this is via T extends string | number which neither conveys the intent of the programmer, nor imposes the requisite type enforcement.
export enum StandardSortOrder {
Default,
Most,
Least
}
export enum AlternativeSortOrder {
Default,
High,
Medium,
Low
}
export interface IThingThatUsesASortOrder<T extends enum> { // doesn't compile
sortOrder: T;
}
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue の enum の例から始め、T extends enum 制約の意図されたセマンティクスを明確にしてください。これには、どの enum 型を受け入れるべきか、また型の強制が何を意味するのかを含みます。ソースファイル、エントリーポイント、テストのいずれも指定されていないため、この作業ではコンパイラーのジェネリック制約処理を見つけ、提案された動作のカバレッジを追加する必要があります。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100