-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Detect circularities printing recursive conditional types #43733
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d45a418
Add failing (crashing) test
andrewbranch 264b914
Simplify repro
andrewbranch aa5519d
Add full test case (still fails)
andrewbranch 54ee902
Merge branch 'master' into bug/43529
andrewbranch 0f4e922
Cache accessibe symbol chains, type parameter name generation
weswigham 60be8f1
Move signature declaration helper length approximation to start of fu…
weswigham 52499b1
Add node result caching internal to `typeToTypeNodeHelper`
weswigham 1360db8
Suggestion from PR
weswigham 909d519
Merge branch 'master' into declaration-emit-performance
weswigham 8eb6a6e
Merge branch 'declaration-emit-performance' into bug/43529
andrewbranch e283acc
Merge branch 'master' into bug/43529
andrewbranch d08bf3b
Accept baselines
andrewbranch a11c20c
Merge branch 'main' into bug/43529
andrewbranch a580635
Accept baseline change
andrewbranch b90ef95
Fix merge-induced lint errors
andrewbranch 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
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
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,6 @@ | ||
//// [recursiveConditionalCrash1.ts] | ||
type C1<T> = [T extends string ? C1<T> : never][0]; | ||
type C2<T> = [T extends string ? [C2<T>] : never][0]; | ||
|
||
|
||
//// [recursiveConditionalCrash1.js] |
15 changes: 15 additions & 0 deletions
15
tests/baselines/reference/recursiveConditionalCrash1.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,15 @@ | ||
=== tests/cases/compiler/recursiveConditionalCrash1.ts === | ||
type C1<T> = [T extends string ? C1<T> : never][0]; | ||
>C1 : Symbol(C1, Decl(recursiveConditionalCrash1.ts, 0, 0)) | ||
>T : Symbol(T, Decl(recursiveConditionalCrash1.ts, 0, 8)) | ||
>T : Symbol(T, Decl(recursiveConditionalCrash1.ts, 0, 8)) | ||
>C1 : Symbol(C1, Decl(recursiveConditionalCrash1.ts, 0, 0)) | ||
>T : Symbol(T, Decl(recursiveConditionalCrash1.ts, 0, 8)) | ||
|
||
type C2<T> = [T extends string ? [C2<T>] : never][0]; | ||
>C2 : Symbol(C2, Decl(recursiveConditionalCrash1.ts, 0, 51)) | ||
>T : Symbol(T, Decl(recursiveConditionalCrash1.ts, 1, 8)) | ||
>T : Symbol(T, Decl(recursiveConditionalCrash1.ts, 1, 8)) | ||
>C2 : Symbol(C2, Decl(recursiveConditionalCrash1.ts, 0, 51)) | ||
>T : Symbol(T, Decl(recursiveConditionalCrash1.ts, 1, 8)) | ||
|
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,7 @@ | ||
=== tests/cases/compiler/recursiveConditionalCrash1.ts === | ||
type C1<T> = [T extends string ? C1<T> : never][0]; | ||
>C1 : T extends string ? T extends string ? T extends string ? T extends string ? T extends string ? T extends string ? T extends string ? T extends string ? T extends string ? T extends string ? T extends string ? any : never : never : never : never : never : never : never : never : never : never : never | ||
|
||
type C2<T> = [T extends string ? [C2<T>] : never][0]; | ||
>C2 : T extends string ? [T extends string ? [T extends string ? [T extends string ? [T extends string ? [T extends string ? [T extends string ? [T extends string ? [T extends string ? [T extends string ? [T extends string ? [any] : never] : never] : never] : never] : never] : never] : never] : never] : never] : never] : never | ||
|
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,21 @@ | ||
//// [recursiveConditionalCrash2.ts] | ||
// Simplified #43529 | ||
|
||
export type CanBeExpanded<T extends object> = { | ||
value: T | ||
} | ||
|
||
type Expand__<O, N, Depth> = | ||
N extends Depth ? | ||
unknown : | ||
O extends CanBeExpanded<any> ? | ||
Expand__<O['value'], N, Depth> : | ||
O | ||
|
||
export type UseQueryOptions<T> = Expand__<T, 4, 2> | ||
|
||
|
||
//// [recursiveConditionalCrash2.js] | ||
"use strict"; | ||
// Simplified #43529 | ||
exports.__esModule = true; |
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.
Uh, is this change ok @weswigham?
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.
I'm... Not even sure what's different at a glance
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.
Uhh... Yeah, it's probably fine - there's an
any
due to truncation in the removed type text, so all we did was truncate more, which is generally fine.