-
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
Inconsistencies with empty intersection types #25730
Comments
I may have missed something, but where are you getting that "foo" & "bar" should become "undefined"? I've never seen that mentioned anywhere. |
I think you meant The inconsistency here is because intersections are only reduced when used in a union. so We have found that keeping the intersections longer gives better error messages to users, since |
When strictNullChecks is off,
OK re this part. Thanks for taking the time to explain. |
we consider |
I confess I don't understand how you come to this conclusion. If #12825 is implemented, couldn't this lead (under admittedly unlikely circumstances) to a call to a generic function unexpectedly stopping the control flow when the function was supposed to return |
We did not have union types, and we did not have manifest types for |
Were there any other related discussions? It's very counterintuitive that |
Two orthogonal problems with empty intersection types:
never
. It should beundefined
when strictNullChecks is disabled.I thought filing one issue might make less work for the TypeScript team. If you agree with the proposed changes, this should be an easy pull request (I've already looked at the code involved) and I'll be happy to submit it.
TypeScript Version: master (d9ed917)
Search Terms: empty intersection unit type undefined union never strictNullChecks
Code
Expected behavior:
x
,xx
have the same type, and (assuming strictNullChecks is disabled) that type isundefined
.Actual behavior: As marked.
Playground Link: link
Related Issues: None found
The text was updated successfully, but these errors were encountered: