microsoft / microsoft/TypeScript

3.4.1 regression in distributed types

オープン
#31,121 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

説明

TypeScript Version: 3.5.0-dev.20190425

The example below was taken from a real world use-case and simplified.

The U type is distributed while the T type remains the original union.

The T type is wrapped with Box<T> when U is not an object.

type Box<T> = { value: T }
type Test<T> = [T] extends [infer U]
  ? U extends object
    ? U
    : U | Box<T>
  : never

type A = number | { foo: number }
type B = Test<A>

In theory, the B type should be identical to:

type B = number | { foo: number } | Box<number | { foo: number }>

But in the latest version, the B type is instead identical to:

type B = number | { foo: number } | Box<number | (number & { foo: number })>

This works correctly in 3.3.x but not 3.4.x and later.

Playground Link: click here

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

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

はじめの一歩

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

調査の方向性

リンクされた Playground の再現から始め、TypeScript 3.3.x と 3.4.x 以降での動作を比較してください。T を保持しながら条件型が U をどのように分配するかを追跡し、B が Box 内部の交差型を含まない、記載された期待されるユニオンと一致したら issue 完了とします。

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

評価

技術スタック
typescript
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

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

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