microsoft / microsoft/TypeScript
String literal type inconsistency in overload resolution
まだ誰も着手していません。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
As far as I see, the TS compiler still sees a string literal type of a single literal as an old style "string parameter" thing. I thought that the concept of string literal types should replace overloading on string parameters, but seems that it doesn't.
That complicates things, and results in a "strange" behaviour in overload resolution:
class A256 {
m(a): any;
m(a: "a" | "b"): string;
m(a: "c"): string;
m(a): any {}
}
var foo1 = new A256().m("a"); // 'any'
var foo2 = new A256().m("c"); // 'string'
What should be the correct logic with string literal types in overload resolution?
Shouldn't overloads with unions of literals precede the others as well, when resolving overloads?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず A256 の例をコンパイルし、foo1 と foo2 の推論された型を、期待されるオーバーロードの動作と比較します。次に、文字列リテラルのユニオンに対するコンパイラーのオーバーロード解決処理を追跡します。完了の条件は、動作が定義され、そのルールに従って例が一貫して解決され、関連するテストの場所が特定された場合はリグレッションテストのカバレッジが追加されていることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100