microsoft / microsoft/TypeScript
Suggestion: consolidate generics in union if they match
オープン
まだ誰も着手していません。
Awaiting More Feedback
Suggestion
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
TypeScript Version: 3.5.2
Search Terms: rxjs startWith generics union consolidate same
Code
declare const create: <T>(
t: T,
) => {
startWith: <D>(v1: D) => T | D;
};
// Succeeds
// $ExpectType { foo: number } | { bar: number }
const r1 = create({ foo: 1 }).startWith({ bar: 1 });
// Fails
// $ExpectType { foo: number }
// Actual: { foo: number } | { foo: number }
const r2 = create({ foo: 1 }).startWith({ foo: 1 });
Although the expected/actual types are compatible, it's slightly irritating to deal with a union type T | T instead of a consolidated type T, as it makes type inspection in VS Code much more difficult (especially when the types are large or deeply nested).
Real world use case: https://github.com/ReactiveX/rxjs/issues/4866
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された create/startWith の例を TypeScript 3.5.2 で再現し、r1 と r2 に対して推論された型を調べます。同一のジェネリック結果のユニオンを処理する型チェックの経路を調査します。対応するユニオンが単一の型として表現され、異なるユニオンの場合が変更されなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100