-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Union type inference lost on assignment #23523
Comments
We track these guards based on the expressions used to test them; unfortunately the type checker is not implemented in a way that it actually understands that |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.9.0-dev.20180418
Search Terms: union type strictnullchecks inference
Code
Expected behavior:
Passes type checker. Since
person.address.street
is eithernull
or a string, and since there is a check on line 13 forperson.address.street
being truthy, we know thataddress.street
is a string.You can get the type checker to pass by omitting the reassignment:
Actual behavior:
Playground Link: playground link
Related Issues:
#22635
#16069
The text was updated successfully, but these errors were encountered: