-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Unable to infer the inner type within expansion of a nested union #26807
Comments
This is a design limitation of our inference algorithm. Specifically, if, during inference, we are already processing another target type with the same associated symbol (such as an instantiation of the same generic type), we do not explore the nested target as it rarely yields further inferences, but definitely generates lots of work. Obviously that's not a good strategy here. |
I see. Any chance of the design being revisited? 🙂 |
@ahejlsberg is there any way to force that exploration somehow? (forcing being enforced by library authors at definition site) |
I've checked and starting from Typescript@4.1.5 this is fixed see playground link /cc @pelotom |
Since this is fixed, this issue shouldn't be open, no? |
Yep! |
TypeScript Version: 3.0.1, 3.0.3, 3.1.0-dev.20180831
Search Terms: infer nested union type
Code
Expected behavior:
The types
X
andY
should both benumber
, becauseMaybeMaybeNumber
is just an expansion ofMaybe<Maybe<number>>
.Actual behavior:
X
isnumber
, butY
is{}
.Playground Link
The text was updated successfully, but these errors were encountered: