-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Type argument inference fix for infinitely recursive anonymous types #3452
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9c4d309
Move inferFromTypes to use isDeeplyNestedGeneric
JsonFreeman 8eb1ecb
Unravel some conditions
JsonFreeman 04b4bc2
Add test
JsonFreeman f2e04f2
Fix white space
JsonFreeman 9f26803
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
JsonFreeman 80f523c
Change depth limit from 10 to 5 in isDeeplyNestedGeneric
JsonFreeman aeda847
Merge branch 'master' of https://github.com/Microsoft/TypeScript into…
JsonFreeman 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 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
39 changes: 39 additions & 0 deletions
39
tests/baselines/reference/cyclicGenericTypeInstantiationInference.js
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,39 @@ | ||
//// [cyclicGenericTypeInstantiationInference.ts] | ||
function foo<T>() { | ||
var z = foo<typeof y>(); | ||
var y: { | ||
y2: typeof z | ||
}; | ||
return y; | ||
} | ||
|
||
|
||
function bar<T>() { | ||
var z = bar<typeof y>(); | ||
var y: { | ||
y2: typeof z; | ||
} | ||
return y; | ||
} | ||
|
||
var a = foo<number>(); | ||
var b = bar<number>(); | ||
|
||
function test<T>(x: typeof a): void { } | ||
test(b); | ||
|
||
//// [cyclicGenericTypeInstantiationInference.js] | ||
function foo() { | ||
var z = foo(); | ||
var y; | ||
return y; | ||
} | ||
function bar() { | ||
var z = bar(); | ||
var y; | ||
return y; | ||
} | ||
var a = foo(); | ||
var b = bar(); | ||
function test(x) { } | ||
test(b); |
61 changes: 61 additions & 0 deletions
61
tests/baselines/reference/cyclicGenericTypeInstantiationInference.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,61 @@ | ||
=== tests/cases/compiler/cyclicGenericTypeInstantiationInference.ts === | ||
function foo<T>() { | ||
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 0)) | ||
>T : Symbol(T, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 13)) | ||
|
||
var z = foo<typeof y>(); | ||
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 1, 7)) | ||
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 0)) | ||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 7)) | ||
|
||
var y: { | ||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 7)) | ||
|
||
y2: typeof z | ||
>y2 : Symbol(y2, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 12)) | ||
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 1, 7)) | ||
|
||
}; | ||
return y; | ||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 7)) | ||
} | ||
|
||
|
||
function bar<T>() { | ||
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiationInference.ts, 6, 1)) | ||
>T : Symbol(T, Decl(cyclicGenericTypeInstantiationInference.ts, 9, 13)) | ||
|
||
var z = bar<typeof y>(); | ||
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 10, 7)) | ||
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiationInference.ts, 6, 1)) | ||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 7)) | ||
|
||
var y: { | ||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 7)) | ||
|
||
y2: typeof z; | ||
>y2 : Symbol(y2, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 12)) | ||
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 10, 7)) | ||
} | ||
return y; | ||
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 7)) | ||
} | ||
|
||
var a = foo<number>(); | ||
>a : Symbol(a, Decl(cyclicGenericTypeInstantiationInference.ts, 17, 3)) | ||
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 0)) | ||
|
||
var b = bar<number>(); | ||
>b : Symbol(b, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 3)) | ||
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiationInference.ts, 6, 1)) | ||
|
||
function test<T>(x: typeof a): void { } | ||
>test : Symbol(test, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 22)) | ||
>T : Symbol(T, Decl(cyclicGenericTypeInstantiationInference.ts, 20, 14)) | ||
>x : Symbol(x, Decl(cyclicGenericTypeInstantiationInference.ts, 20, 17)) | ||
>a : Symbol(a, Decl(cyclicGenericTypeInstantiationInference.ts, 17, 3)) | ||
|
||
test(b); | ||
>test : Symbol(test, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 22)) | ||
>b : Symbol(b, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 3)) | ||
|
66 changes: 66 additions & 0 deletions
66
tests/baselines/reference/cyclicGenericTypeInstantiationInference.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,66 @@ | ||
=== tests/cases/compiler/cyclicGenericTypeInstantiationInference.ts === | ||
function foo<T>() { | ||
>foo : <T>() => { y2: any; } | ||
>T : T | ||
|
||
var z = foo<typeof y>(); | ||
>z : { y2: any; } | ||
>foo<typeof y>() : { y2: any; } | ||
>foo : <T>() => { y2: any; } | ||
>y : { y2: any; } | ||
|
||
var y: { | ||
>y : { y2: any; } | ||
|
||
y2: typeof z | ||
>y2 : { y2: any; } | ||
>z : { y2: any; } | ||
|
||
}; | ||
return y; | ||
>y : { y2: any; } | ||
} | ||
|
||
|
||
function bar<T>() { | ||
>bar : <T>() => { y2: any; } | ||
>T : T | ||
|
||
var z = bar<typeof y>(); | ||
>z : { y2: any; } | ||
>bar<typeof y>() : { y2: any; } | ||
>bar : <T>() => { y2: any; } | ||
>y : { y2: any; } | ||
|
||
var y: { | ||
>y : { y2: any; } | ||
|
||
y2: typeof z; | ||
>y2 : { y2: any; } | ||
>z : { y2: any; } | ||
} | ||
return y; | ||
>y : { y2: any; } | ||
} | ||
|
||
var a = foo<number>(); | ||
>a : { y2: any; } | ||
>foo<number>() : { y2: any; } | ||
>foo : <T>() => { y2: any; } | ||
|
||
var b = bar<number>(); | ||
>b : { y2: any; } | ||
>bar<number>() : { y2: any; } | ||
>bar : <T>() => { y2: any; } | ||
|
||
function test<T>(x: typeof a): void { } | ||
>test : <T>(x: { y2: any; }) => void | ||
>T : T | ||
>x : { y2: any; } | ||
>a : { y2: any; } | ||
|
||
test(b); | ||
>test(b) : void | ||
>test : <T>(x: { y2: any; }) => void | ||
>b : { y2: any; } | ||
|
22 changes: 22 additions & 0 deletions
22
tests/cases/compiler/cyclicGenericTypeInstantiationInference.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,22 @@ | ||
function foo<T>() { | ||
var z = foo<typeof y>(); | ||
var y: { | ||
y2: typeof z | ||
}; | ||
return y; | ||
} | ||
|
||
|
||
function bar<T>() { | ||
var z = bar<typeof y>(); | ||
var y: { | ||
y2: typeof z; | ||
} | ||
return y; | ||
} | ||
|
||
var a = foo<number>(); | ||
var b = bar<number>(); | ||
|
||
function test<T>(x: typeof a): void { } | ||
test(b); |
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.
What is with this brace?
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.
That is a white space management error