Improve checks for infinitely expanding recursive conditional types#46326
Improve checks for infinitely expanding recursive conditional types#46326ahejlsberg merged 5 commits intomainfrom
Conversation
|
I haven't added regression tests yet, but have manually verified that both listed issues are fixed. |
weswigham
left a comment
There was a problem hiding this comment.
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. 😄
| 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.
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.
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.
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.