microsoft / microsoft/TypeScript
Conditional types behavior is different when referencing same type with different name
Offen
@weswigham arbeitet bereits daran.
Seit 08.7.2021.
Bug
Domain: Conditional Types
Rescheduled
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.