microsoft / microsoft/TypeScript
A trivial generic interface extending a generic type handles assignability differently than the base type
オープン
まだ誰も着手していません。
Needs Investigation
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.4k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 117
説明
TypeScript Version: 4.0.5, 4.1.0-beta, 4.1.0-dev.20201102
Search Terms: generic interface assignability
Code
type Assert<T, U extends T> = U;
type A = { value: 5, a: true };
type B = { value: 5, b: true };
interface Box<T> {
value: T;
}
type _Rebox<T extends Box<any>> = Box<T["value"]>;
namespace Test0 {
type Rebox<T extends Box<any>> = _Rebox<T>;
export type Assertions = [
Assert<Box<5>, Rebox<A>>, // Correctly passes
Assert<Rebox<A>, Box<5>>, // Correctly passes
Assert<Box<5>, Rebox<B>>, // Correctly passes
Assert<Rebox<B>, Box<5>>, // Correctly passes
Assert<Rebox<A>, Rebox<B>>, // Correctly passes
];
}
namespace Test1 {
interface Rebox<T extends Box<any>> extends _Rebox<T> {};
export type Assertions = [
Assert<Box<5>, Rebox<A>>, // Correctly passes
Assert<Rebox<A>, Box<5>>, // Correctly passes
Assert<Box<5>, Rebox<B>>, // Correctly passes
Assert<Rebox<B>, Box<5>>, // Correctly passes
Assert<Rebox<A>, Rebox<B>>, // Incorrectly fails
];
}
Expected behavior: Test0.Assertions and Test1.Assertions should both resolve with no errors.
Actual behavior: When Rebox is an interface (in Test1), Rebox<B> is not assignable to Rebox<A>.
Related Issues: N/A
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue にある TypeScript の再現コードから始め、Test0 と Test1 における型エイリアス形式とインターフェース形式の代入可能性の結果を比較します。コンパイラーのジェネリックインターフェースと代入可能性に関する挙動を追跡し、Rebox が Rebox に代入可能であり、両方のアサーションセットがエラーなしで解決されることを示すリグレッションテストを追加します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- typescript
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100