microsoft / microsoft/TypeScript

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

Aperta
#44,945 1 commento 2 reazioni 1 assegnatario Vedi su GitHub

@weswigham ci sta già lavorando.

Dal 8/7/2021.

Bug Domain: Conditional Types Rescheduled
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.