-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Improve checks for infinitely expanding recursive conditional types #46326
Conversation
I haven't added regression tests yet, but have manually verified that both listed issues are fixed. |
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.
New regression tests that more closely reflect the reported issues would be nice, but in terms of implementation, this is pretty much what I proposed, so I'm obviously OK with it. 😄
@@ -64,6 +63,4 @@ tests/cases/compiler/infiniteConstraints.ts(48,27): error TS2321: Excessive stac | |||
|
|||
type Conv<T, U = T> = | |||
{ 0: [T]; 1: Prepend<T, Conv<ExactExtract<U, T>>>;}[U extends T ? 0 : 1]; | |||
~~~~~~~~~~~~~~~~~~~~~~~~ | |||
!!! error TS2321: Excessive stack depth comparing types 'Conv<ExactExtract<U, T>, ExactExtract<U, T>>' and 'unknown[]'. |
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.
This test has flip-flopped weather or not there's an error here so many times. I guess that's what it's here for, though.
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.
Yeah, but it's a good change. The excessive stack depth error is basically a panic bail out, in this case triggered by a missing check for infinite conditional type recursion on the target side.
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.
Yeah, I just chuckle because when this test was first added it had this error, then it got removed by another change, then it got added back, and now it's being removed again. This test is surprisingly good at capturing how strict we are about comparing infinite types, even if that's not what it was meant to test (it was meant to test a crash).
@typescript-bot perf test this |
Heya @ahejlsberg, I've started to run the perf test suite on this PR at 6c633e6. You can monitor the build here. Update: The results are in! |
@ahejlsberg Here they are:Comparison Report - main..46326
System
Hosts
Scenarios
Developer Information: |
Fixes #46183.
Fixes #46316.