-
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
Conditional types incorrect for complex types #35533
Comments
I think there is 5 level limit on recursive types. This Build 2018 presentation is the source of my understanding. Though, might not be the case anymore after 3.7.*. |
Whatever the limit is, I think TS should never implicitly cast something to |
The limitation described in the Build talk is still accurate. This isn't an "implicit casting to |
Thanks, that makes sense – but I'm still a little wary of silently assuming the answer is "yes." Is it possible to issue a warning instead, or is it difficult to evaluate whether we're in this situation? |
I believe this is actually fixed by #46599 – thanks!
This is awesome. So, no longer a design limitation :) |
TypeScript Version: 3.7.2
I'm seeing incorrect behavior when I
extend
a computed type that's more than a few levels deep. When I explicitly define the type, I don't see the same behavior. I'm guessing that complex types are getting implicitly cast toany
in this circumstance – tsc should probably either instantiate the correct type or cast them tounknown
with a warning when they're too big.This is admittedly a contrived example but I've run into similar issues when, for example, developing https://github.com/ostrowr/ts-json-validator
Search Terms:
depth, conditional types, extends, implicit any
Expected behavior:
shouldBeFalse
andcorrectlyFalseWhenExpanded
are bothfalse
(see code snippet below)Actual behavior:
shouldBeFalse
is True (i.e. 6 == 5 in my contrived version of Peano arithmetic)Related Issues:
Code
Output
Compiler Options
Playground Link: Provided
The text was updated successfully, but these errors were encountered: