microsoft / microsoft/TypeScript

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

Đang mở
#44,945 1 bình luận 2 reaction 1 người được giao Xem trên GitHub

@weswigham đang làm issue này rồi.

Từ ngày 8/7/2021.

Bug Domain: Conditional Types Rescheduled
Ngôn ngữ chính
Go
Star
111k
Fork
14.4k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.