-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Apply isLiteralContextualType recursively for unions and intersections. #19684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
50 changes: 50 additions & 0 deletions
50
tests/baselines/reference/genericCallStringLiteralUnionNested.errors.txt
This file contains hidden or 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,50 @@ | ||
tests/cases/compiler/genericCallStringLiteralUnionNested.ts(23,7): error TS2322: Type 'string[]' is not assignable to type '"z"[]'. | ||
Type 'string' is not assignable to type '"z"'. | ||
tests/cases/compiler/genericCallStringLiteralUnionNested.ts(24,7): error TS2322: Type 'number[]' is not assignable to type '1[]'. | ||
Type 'number' is not assignable to type '1'. | ||
tests/cases/compiler/genericCallStringLiteralUnionNested.ts(27,7): error TS2322: Type 'string[]' is not assignable to type '"z"[]'. | ||
tests/cases/compiler/genericCallStringLiteralUnionNested.ts(28,7): error TS2322: Type 'number[]' is not assignable to type '3[]'. | ||
Type 'number' is not assignable to type '3'. | ||
|
||
|
||
==== tests/cases/compiler/genericCallStringLiteralUnionNested.ts (4 errors) ==== | ||
declare function nestedUnionExtendsString<A extends string>(a: { fields: A | A[] }): Record<A, string>; | ||
const t1: {z: string} = nestedUnionExtendsString({ fields: "z" }); | ||
|
||
declare function nestedUnionExtendsLiterals<A extends "z" | "y">(a: { fields: A | A[] }): A[]; | ||
const t2: "z"[] = nestedUnionExtendsLiterals({ fields: "z" }); | ||
|
||
declare function nestedGenericIntersection<A extends B & C, B extends string, C extends string>(a: { fields: A | A[] }, b: B[], c: C[]): A[]; | ||
const t3: "z"[] = nestedGenericIntersection({ fields: "z" }, ["z", "y"], ["z", "y"]); | ||
|
||
declare function nestedUnionExtendsNumber<A extends number>(a: { fields: A | A[] }): A[]; | ||
const t4: 1[] = nestedUnionExtendsNumber({ fields: 1 }); | ||
|
||
declare function nestedUnionExtendsLiteralsNumber<A extends 1 | 2>(a: { fields: A | A[] }): A[]; | ||
const t5: 2[] = nestedUnionExtendsLiteralsNumber({ fields: 2 }); | ||
|
||
declare function nestedUnionIntersectionGenericNumber<A extends B & C, B extends number, C extends number>(a: { fields: A | A[] }, b: B[], c: C[]): A[]; | ||
const t6: 3[] = nestedUnionIntersectionGenericNumber({ fields: 3 }, [1, 3], [1, 3]); | ||
|
||
|
||
// The following are expected to fail because they don't have an extend string or extend number generic constraint. | ||
|
||
declare function nestedUnionPlain<A>(a: { fields: A | A[] }): A[]; | ||
const expectedFail1: "z"[] = nestedUnionPlain({ fields: "z" }); | ||
~~~~~~~~~~~~~ | ||
!!! error TS2322: Type 'string[]' is not assignable to type '"z"[]'. | ||
!!! error TS2322: Type 'string' is not assignable to type '"z"'. | ||
const expectedFail2: 1[] = nestedUnionPlain({ fields: 1 }); | ||
~~~~~~~~~~~~~ | ||
!!! error TS2322: Type 'number[]' is not assignable to type '1[]'. | ||
!!! error TS2322: Type 'number' is not assignable to type '1'. | ||
|
||
declare function nestedUnionIntersectionPlainGenerics<A extends B & C, B, C>(a: { fields: A | A[] }, b: B[], c: C[]): A[]; | ||
const expectedFail3: "z"[] = nestedUnionIntersectionPlainGenerics({ fields: "z" }, ["z", "y"], ["z", "y"]); | ||
~~~~~~~~~~~~~ | ||
!!! error TS2322: Type 'string[]' is not assignable to type '"z"[]'. | ||
const expectedFail4: 3[] = nestedUnionIntersectionPlainGenerics({ fields: 3 }, [1, 3], [1, 3]); | ||
~~~~~~~~~~~~~ | ||
!!! error TS2322: Type 'number[]' is not assignable to type '3[]'. | ||
!!! error TS2322: Type 'number' is not assignable to type '3'. | ||
|
42 changes: 42 additions & 0 deletions
42
tests/baselines/reference/genericCallStringLiteralUnionNested.js
This file contains hidden or 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,42 @@ | ||
//// [genericCallStringLiteralUnionNested.ts] | ||
declare function nestedUnionExtendsString<A extends string>(a: { fields: A | A[] }): Record<A, string>; | ||
const t1: {z: string} = nestedUnionExtendsString({ fields: "z" }); | ||
|
||
declare function nestedUnionExtendsLiterals<A extends "z" | "y">(a: { fields: A | A[] }): A[]; | ||
const t2: "z"[] = nestedUnionExtendsLiterals({ fields: "z" }); | ||
|
||
declare function nestedGenericIntersection<A extends B & C, B extends string, C extends string>(a: { fields: A | A[] }, b: B[], c: C[]): A[]; | ||
const t3: "z"[] = nestedGenericIntersection({ fields: "z" }, ["z", "y"], ["z", "y"]); | ||
|
||
declare function nestedUnionExtendsNumber<A extends number>(a: { fields: A | A[] }): A[]; | ||
const t4: 1[] = nestedUnionExtendsNumber({ fields: 1 }); | ||
|
||
declare function nestedUnionExtendsLiteralsNumber<A extends 1 | 2>(a: { fields: A | A[] }): A[]; | ||
const t5: 2[] = nestedUnionExtendsLiteralsNumber({ fields: 2 }); | ||
|
||
declare function nestedUnionIntersectionGenericNumber<A extends B & C, B extends number, C extends number>(a: { fields: A | A[] }, b: B[], c: C[]): A[]; | ||
const t6: 3[] = nestedUnionIntersectionGenericNumber({ fields: 3 }, [1, 3], [1, 3]); | ||
|
||
|
||
// The following are expected to fail because they don't have an extend string or extend number generic constraint. | ||
|
||
declare function nestedUnionPlain<A>(a: { fields: A | A[] }): A[]; | ||
const expectedFail1: "z"[] = nestedUnionPlain({ fields: "z" }); | ||
const expectedFail2: 1[] = nestedUnionPlain({ fields: 1 }); | ||
|
||
declare function nestedUnionIntersectionPlainGenerics<A extends B & C, B, C>(a: { fields: A | A[] }, b: B[], c: C[]): A[]; | ||
const expectedFail3: "z"[] = nestedUnionIntersectionPlainGenerics({ fields: "z" }, ["z", "y"], ["z", "y"]); | ||
const expectedFail4: 3[] = nestedUnionIntersectionPlainGenerics({ fields: 3 }, [1, 3], [1, 3]); | ||
|
||
|
||
//// [genericCallStringLiteralUnionNested.js] | ||
var t1 = nestedUnionExtendsString({ fields: "z" }); | ||
var t2 = nestedUnionExtendsLiterals({ fields: "z" }); | ||
var t3 = nestedGenericIntersection({ fields: "z" }, ["z", "y"], ["z", "y"]); | ||
var t4 = nestedUnionExtendsNumber({ fields: 1 }); | ||
var t5 = nestedUnionExtendsLiteralsNumber({ fields: 2 }); | ||
var t6 = nestedUnionIntersectionGenericNumber({ fields: 3 }, [1, 3], [1, 3]); | ||
var expectedFail1 = nestedUnionPlain({ fields: "z" }); | ||
var expectedFail2 = nestedUnionPlain({ fields: 1 }); | ||
var expectedFail3 = nestedUnionIntersectionPlainGenerics({ fields: "z" }, ["z", "y"], ["z", "y"]); | ||
var expectedFail4 = nestedUnionIntersectionPlainGenerics({ fields: 3 }, [1, 3], [1, 3]); |
152 changes: 152 additions & 0 deletions
152
tests/baselines/reference/genericCallStringLiteralUnionNested.symbols
This file contains hidden or 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,152 @@ | ||
=== tests/cases/compiler/genericCallStringLiteralUnionNested.ts === | ||
declare function nestedUnionExtendsString<A extends string>(a: { fields: A | A[] }): Record<A, string>; | ||
>nestedUnionExtendsString : Symbol(nestedUnionExtendsString, Decl(genericCallStringLiteralUnionNested.ts, 0, 0)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 0, 42)) | ||
>a : Symbol(a, Decl(genericCallStringLiteralUnionNested.ts, 0, 60)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 0, 64)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 0, 42)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 0, 42)) | ||
>Record : Symbol(Record, Decl(lib.d.ts, --, --)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 0, 42)) | ||
|
||
const t1: {z: string} = nestedUnionExtendsString({ fields: "z" }); | ||
>t1 : Symbol(t1, Decl(genericCallStringLiteralUnionNested.ts, 1, 5)) | ||
>z : Symbol(z, Decl(genericCallStringLiteralUnionNested.ts, 1, 11)) | ||
>nestedUnionExtendsString : Symbol(nestedUnionExtendsString, Decl(genericCallStringLiteralUnionNested.ts, 0, 0)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 1, 50)) | ||
|
||
declare function nestedUnionExtendsLiterals<A extends "z" | "y">(a: { fields: A | A[] }): A[]; | ||
>nestedUnionExtendsLiterals : Symbol(nestedUnionExtendsLiterals, Decl(genericCallStringLiteralUnionNested.ts, 1, 66)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 3, 44)) | ||
>a : Symbol(a, Decl(genericCallStringLiteralUnionNested.ts, 3, 65)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 3, 69)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 3, 44)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 3, 44)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 3, 44)) | ||
|
||
const t2: "z"[] = nestedUnionExtendsLiterals({ fields: "z" }); | ||
>t2 : Symbol(t2, Decl(genericCallStringLiteralUnionNested.ts, 4, 5)) | ||
>nestedUnionExtendsLiterals : Symbol(nestedUnionExtendsLiterals, Decl(genericCallStringLiteralUnionNested.ts, 1, 66)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 4, 46)) | ||
|
||
declare function nestedGenericIntersection<A extends B & C, B extends string, C extends string>(a: { fields: A | A[] }, b: B[], c: C[]): A[]; | ||
>nestedGenericIntersection : Symbol(nestedGenericIntersection, Decl(genericCallStringLiteralUnionNested.ts, 4, 62)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 6, 43)) | ||
>B : Symbol(B, Decl(genericCallStringLiteralUnionNested.ts, 6, 59)) | ||
>C : Symbol(C, Decl(genericCallStringLiteralUnionNested.ts, 6, 77)) | ||
>B : Symbol(B, Decl(genericCallStringLiteralUnionNested.ts, 6, 59)) | ||
>C : Symbol(C, Decl(genericCallStringLiteralUnionNested.ts, 6, 77)) | ||
>a : Symbol(a, Decl(genericCallStringLiteralUnionNested.ts, 6, 96)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 6, 100)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 6, 43)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 6, 43)) | ||
>b : Symbol(b, Decl(genericCallStringLiteralUnionNested.ts, 6, 119)) | ||
>B : Symbol(B, Decl(genericCallStringLiteralUnionNested.ts, 6, 59)) | ||
>c : Symbol(c, Decl(genericCallStringLiteralUnionNested.ts, 6, 127)) | ||
>C : Symbol(C, Decl(genericCallStringLiteralUnionNested.ts, 6, 77)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 6, 43)) | ||
|
||
const t3: "z"[] = nestedGenericIntersection({ fields: "z" }, ["z", "y"], ["z", "y"]); | ||
>t3 : Symbol(t3, Decl(genericCallStringLiteralUnionNested.ts, 7, 5)) | ||
>nestedGenericIntersection : Symbol(nestedGenericIntersection, Decl(genericCallStringLiteralUnionNested.ts, 4, 62)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 7, 45)) | ||
|
||
declare function nestedUnionExtendsNumber<A extends number>(a: { fields: A | A[] }): A[]; | ||
>nestedUnionExtendsNumber : Symbol(nestedUnionExtendsNumber, Decl(genericCallStringLiteralUnionNested.ts, 7, 85)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 9, 42)) | ||
>a : Symbol(a, Decl(genericCallStringLiteralUnionNested.ts, 9, 60)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 9, 64)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 9, 42)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 9, 42)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 9, 42)) | ||
|
||
const t4: 1[] = nestedUnionExtendsNumber({ fields: 1 }); | ||
>t4 : Symbol(t4, Decl(genericCallStringLiteralUnionNested.ts, 10, 5)) | ||
>nestedUnionExtendsNumber : Symbol(nestedUnionExtendsNumber, Decl(genericCallStringLiteralUnionNested.ts, 7, 85)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 10, 42)) | ||
|
||
declare function nestedUnionExtendsLiteralsNumber<A extends 1 | 2>(a: { fields: A | A[] }): A[]; | ||
>nestedUnionExtendsLiteralsNumber : Symbol(nestedUnionExtendsLiteralsNumber, Decl(genericCallStringLiteralUnionNested.ts, 10, 56)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 12, 50)) | ||
>a : Symbol(a, Decl(genericCallStringLiteralUnionNested.ts, 12, 67)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 12, 71)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 12, 50)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 12, 50)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 12, 50)) | ||
|
||
const t5: 2[] = nestedUnionExtendsLiteralsNumber({ fields: 2 }); | ||
>t5 : Symbol(t5, Decl(genericCallStringLiteralUnionNested.ts, 13, 5)) | ||
>nestedUnionExtendsLiteralsNumber : Symbol(nestedUnionExtendsLiteralsNumber, Decl(genericCallStringLiteralUnionNested.ts, 10, 56)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 13, 50)) | ||
|
||
declare function nestedUnionIntersectionGenericNumber<A extends B & C, B extends number, C extends number>(a: { fields: A | A[] }, b: B[], c: C[]): A[]; | ||
>nestedUnionIntersectionGenericNumber : Symbol(nestedUnionIntersectionGenericNumber, Decl(genericCallStringLiteralUnionNested.ts, 13, 64)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 15, 54)) | ||
>B : Symbol(B, Decl(genericCallStringLiteralUnionNested.ts, 15, 70)) | ||
>C : Symbol(C, Decl(genericCallStringLiteralUnionNested.ts, 15, 88)) | ||
>B : Symbol(B, Decl(genericCallStringLiteralUnionNested.ts, 15, 70)) | ||
>C : Symbol(C, Decl(genericCallStringLiteralUnionNested.ts, 15, 88)) | ||
>a : Symbol(a, Decl(genericCallStringLiteralUnionNested.ts, 15, 107)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 15, 111)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 15, 54)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 15, 54)) | ||
>b : Symbol(b, Decl(genericCallStringLiteralUnionNested.ts, 15, 130)) | ||
>B : Symbol(B, Decl(genericCallStringLiteralUnionNested.ts, 15, 70)) | ||
>c : Symbol(c, Decl(genericCallStringLiteralUnionNested.ts, 15, 138)) | ||
>C : Symbol(C, Decl(genericCallStringLiteralUnionNested.ts, 15, 88)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 15, 54)) | ||
|
||
const t6: 3[] = nestedUnionIntersectionGenericNumber({ fields: 3 }, [1, 3], [1, 3]); | ||
>t6 : Symbol(t6, Decl(genericCallStringLiteralUnionNested.ts, 16, 5)) | ||
>nestedUnionIntersectionGenericNumber : Symbol(nestedUnionIntersectionGenericNumber, Decl(genericCallStringLiteralUnionNested.ts, 13, 64)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 16, 54)) | ||
|
||
|
||
// The following are expected to fail because they don't have an extend string or extend number generic constraint. | ||
|
||
declare function nestedUnionPlain<A>(a: { fields: A | A[] }): A[]; | ||
>nestedUnionPlain : Symbol(nestedUnionPlain, Decl(genericCallStringLiteralUnionNested.ts, 16, 84)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 21, 34)) | ||
>a : Symbol(a, Decl(genericCallStringLiteralUnionNested.ts, 21, 37)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 21, 41)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 21, 34)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 21, 34)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 21, 34)) | ||
|
||
const expectedFail1: "z"[] = nestedUnionPlain({ fields: "z" }); | ||
>expectedFail1 : Symbol(expectedFail1, Decl(genericCallStringLiteralUnionNested.ts, 22, 5)) | ||
>nestedUnionPlain : Symbol(nestedUnionPlain, Decl(genericCallStringLiteralUnionNested.ts, 16, 84)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 22, 47)) | ||
|
||
const expectedFail2: 1[] = nestedUnionPlain({ fields: 1 }); | ||
>expectedFail2 : Symbol(expectedFail2, Decl(genericCallStringLiteralUnionNested.ts, 23, 5)) | ||
>nestedUnionPlain : Symbol(nestedUnionPlain, Decl(genericCallStringLiteralUnionNested.ts, 16, 84)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 23, 45)) | ||
|
||
declare function nestedUnionIntersectionPlainGenerics<A extends B & C, B, C>(a: { fields: A | A[] }, b: B[], c: C[]): A[]; | ||
>nestedUnionIntersectionPlainGenerics : Symbol(nestedUnionIntersectionPlainGenerics, Decl(genericCallStringLiteralUnionNested.ts, 23, 59)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 25, 54)) | ||
>B : Symbol(B, Decl(genericCallStringLiteralUnionNested.ts, 25, 70)) | ||
>C : Symbol(C, Decl(genericCallStringLiteralUnionNested.ts, 25, 73)) | ||
>B : Symbol(B, Decl(genericCallStringLiteralUnionNested.ts, 25, 70)) | ||
>C : Symbol(C, Decl(genericCallStringLiteralUnionNested.ts, 25, 73)) | ||
>a : Symbol(a, Decl(genericCallStringLiteralUnionNested.ts, 25, 77)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 25, 81)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 25, 54)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 25, 54)) | ||
>b : Symbol(b, Decl(genericCallStringLiteralUnionNested.ts, 25, 100)) | ||
>B : Symbol(B, Decl(genericCallStringLiteralUnionNested.ts, 25, 70)) | ||
>c : Symbol(c, Decl(genericCallStringLiteralUnionNested.ts, 25, 108)) | ||
>C : Symbol(C, Decl(genericCallStringLiteralUnionNested.ts, 25, 73)) | ||
>A : Symbol(A, Decl(genericCallStringLiteralUnionNested.ts, 25, 54)) | ||
|
||
const expectedFail3: "z"[] = nestedUnionIntersectionPlainGenerics({ fields: "z" }, ["z", "y"], ["z", "y"]); | ||
>expectedFail3 : Symbol(expectedFail3, Decl(genericCallStringLiteralUnionNested.ts, 26, 5)) | ||
>nestedUnionIntersectionPlainGenerics : Symbol(nestedUnionIntersectionPlainGenerics, Decl(genericCallStringLiteralUnionNested.ts, 23, 59)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 26, 67)) | ||
|
||
const expectedFail4: 3[] = nestedUnionIntersectionPlainGenerics({ fields: 3 }, [1, 3], [1, 3]); | ||
>expectedFail4 : Symbol(expectedFail4, Decl(genericCallStringLiteralUnionNested.ts, 27, 5)) | ||
>nestedUnionIntersectionPlainGenerics : Symbol(nestedUnionIntersectionPlainGenerics, Decl(genericCallStringLiteralUnionNested.ts, 23, 59)) | ||
>fields : Symbol(fields, Decl(genericCallStringLiteralUnionNested.ts, 27, 65)) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhegazy That wouldn't accomplish the same thing as my change.
maybeTypeOfKind
actually already did something very similar to what you propose, except that it looked forUnionOrIntersectionType
for the recursion whileforEachType
only looks forUnionType
.The problem is the behavior from #19632 was caused by not extracting the any generic constraint types during the recursion into the unions and intersections.
I did go ahead and refactor the code I wrote to use the core forEach function, and also added a few more test cases.