microsoft / microsoft/TypeScript

Conditional types behavior is different when referencing same type with different name

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

@weswigham がすでに取り組んでいます。

2021年7月8日 から。

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

説明

Bug Report

🔎 Search Terms

conditional types different name

🕗 Version & Regression Information

v4.4.0-beta

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about conditional types
⏯ Playground Link

Playground link with relevant code

💻 Code
type Left<Z> = <T>() => (T extends Z ? 1 : 2);
type Right<Z> = <T>() => (T extends Z ? 1 : 2);

type Equal1<X, Y> = Left<X> extends Right<Y> ? true : false;
type Equal2<X, Y> = Left<X> extends Left<Y> ? true : false;

// false
type X1 = Equal1<{a:string}, {readonly a: string}>
// true
type X2 = Equal2<{a:string}, {readonly a: string}>
🙁 Actual behavior

X1 and X2 is different.

🙂 Expected behavior

X1 and X2 is the same.

Actually, Left and Right are the same, Equal1 and Equal2 are the same.
But the result of Equal1 and Equal2 with the same parameters are different.

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

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

はじめの一歩

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

評価

この issue はまだ評価されていません。

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

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