-
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
Control Flow Type Inference: Inferred Type Varying by Condition Order #11426
Comments
Any idea what's going on here? Can others reproduce? |
The way narrowing works is by removing types from a union. in some cases, where there are two constraints that are not assignable, an intersection is created, e.g. the first clause the second one, I suppose this should be fixed by going deep on the intersection to see if we can remove one of the constituents. though it is not clear how this work in more complex situations. |
@mhegazy Thanks for the explanation! |
This is fixed by #11717 |
TypeScript Version: nightly (2.1.0-dev.20161006)
Code
Expected behavior:
Within the the last two if statements, item should be inferred to be the same type, as both if statements use the same type guards
&&
ed together.Actual behavior:
item
is (correctly, I think) inferred asA & B
in the first if, but asA_or_C_Child & B
in the second.The text was updated successfully, but these errors were encountered: