-
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
Destructuring breaks tagged union case inference #23613
Labels
Duplicate
An existing issue was already created
Comments
Thanks for digging up those issues @mhegazy. This seems like a real issue, so I'm not sure why those were closed out. Maybe it's worth keeping one of them open to track the issue? This is pretty surprising behavior from a user's point of view. |
I would merge this in #9998. these are design limitation for how control flow analysis is implemented. |
Sounds good to me. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
TypeScript Version: 2.8.3
Search Terms: union, destructure
Code
Expected behavior:
TS should infer which case the tagged union falls into regardless of whether or not the parameter is destructured.
data
should be inferred as{ threadId: number, message: string }
.Actual behavior:
data
is inferred as the union of alldata
values inMessage
.Playground Link
The text was updated successfully, but these errors were encountered: