-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed distributive conditional types with never intersections (#57345)
- Loading branch information
Showing
4 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tests/baselines/reference/distributiveConditionalTypeNeverIntersection1.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//// [tests/cases/compiler/distributiveConditionalTypeNeverIntersection1.ts] //// | ||
|
||
=== distributiveConditionalTypeNeverIntersection1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/57343 | ||
|
||
type IsNumber<T> = T extends number ? true : false; | ||
>IsNumber : Symbol(IsNumber, Decl(distributiveConditionalTypeNeverIntersection1.ts, 0, 0)) | ||
>T : Symbol(T, Decl(distributiveConditionalTypeNeverIntersection1.ts, 2, 14)) | ||
>T : Symbol(T, Decl(distributiveConditionalTypeNeverIntersection1.ts, 2, 14)) | ||
|
||
type Conflicted = { x: true } & { x: false }; | ||
>Conflicted : Symbol(Conflicted, Decl(distributiveConditionalTypeNeverIntersection1.ts, 2, 51)) | ||
>x : Symbol(x, Decl(distributiveConditionalTypeNeverIntersection1.ts, 4, 19)) | ||
>x : Symbol(x, Decl(distributiveConditionalTypeNeverIntersection1.ts, 4, 33)) | ||
|
||
type Ex1 = IsNumber<Conflicted>; // never | ||
>Ex1 : Symbol(Ex1, Decl(distributiveConditionalTypeNeverIntersection1.ts, 4, 45)) | ||
>IsNumber : Symbol(IsNumber, Decl(distributiveConditionalTypeNeverIntersection1.ts, 0, 0)) | ||
>Conflicted : Symbol(Conflicted, Decl(distributiveConditionalTypeNeverIntersection1.ts, 2, 51)) | ||
|
||
type Ex2 = IsNumber<"OEEE" | Conflicted>; // false | ||
>Ex2 : Symbol(Ex2, Decl(distributiveConditionalTypeNeverIntersection1.ts, 6, 32)) | ||
>IsNumber : Symbol(IsNumber, Decl(distributiveConditionalTypeNeverIntersection1.ts, 0, 0)) | ||
>Conflicted : Symbol(Conflicted, Decl(distributiveConditionalTypeNeverIntersection1.ts, 2, 51)) | ||
|
||
type Ex3 = IsNumber<1 | Conflicted>; // true | ||
>Ex3 : Symbol(Ex3, Decl(distributiveConditionalTypeNeverIntersection1.ts, 7, 41)) | ||
>IsNumber : Symbol(IsNumber, Decl(distributiveConditionalTypeNeverIntersection1.ts, 0, 0)) | ||
>Conflicted : Symbol(Conflicted, Decl(distributiveConditionalTypeNeverIntersection1.ts, 2, 51)) | ||
|
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/distributiveConditionalTypeNeverIntersection1.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//// [tests/cases/compiler/distributiveConditionalTypeNeverIntersection1.ts] //// | ||
|
||
=== distributiveConditionalTypeNeverIntersection1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/57343 | ||
|
||
type IsNumber<T> = T extends number ? true : false; | ||
>IsNumber : IsNumber<T> | ||
>true : true | ||
>false : false | ||
|
||
type Conflicted = { x: true } & { x: false }; | ||
>Conflicted : never | ||
>x : true | ||
>true : true | ||
>x : false | ||
>false : false | ||
|
||
type Ex1 = IsNumber<Conflicted>; // never | ||
>Ex1 : never | ||
|
||
type Ex2 = IsNumber<"OEEE" | Conflicted>; // false | ||
>Ex2 : false | ||
|
||
type Ex3 = IsNumber<1 | Conflicted>; // true | ||
>Ex3 : true | ||
|
12 changes: 12 additions & 0 deletions
12
tests/cases/compiler/distributiveConditionalTypeNeverIntersection1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @strict: true | ||
// @noEmit: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/57343 | ||
|
||
type IsNumber<T> = T extends number ? true : false; | ||
|
||
type Conflicted = { x: true } & { x: false }; | ||
|
||
type Ex1 = IsNumber<Conflicted>; // never | ||
type Ex2 = IsNumber<"OEEE" | Conflicted>; // false | ||
type Ex3 = IsNumber<1 | Conflicted>; // true |