-
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
2.1 Regression: (A | undefined) & B is possibly undefined #12354
Comments
The current declaration of assign<T, U>(target: T, source: U): T & U; so the result is The language does not have the constructs today to accurately model the behavior of |
Did something change in this regard since 2.0? Because it worked.
Shouldn't the result of |
@mhegazy FWIW, I did https://github.com/types/npm-xtend/blob/master/immutable.d.ts#L1 to allow extending |
@blakeembrey interesting but is that required? The result of This is the behavior of 2.0 and it's a regression, which is not a dupe (I'm not asking for perfect typing, which will come with spread types, I know). |
@jods4 this behavior is introduced in #11717. the change normalizes union types, so that the correct fix for the issue in the OP is by correctly modeling the behavior or |
@mhegazy not sure I understand here. |
|
As an illustration, assume From your own words,
Currently the compiler is complaining that |
the compiler says if the type is the problem is not which rule to invoke. the type You would not write a type annotation on something to be |
OK I see what you mean. It just happened that in 2.0 Surely when the spread types PR lands, Otherwise, since this is an annoying breaking change, maybe you should do a little mitigation in the meantime. You could change the BTW, I tried to think of other cases where |
TypeScript Version: 2.1.? / as shipped with VS 2017 RC
Code
Expected behavior:
x.id
was fine in TS 2.0, and should be as it is guaranteed to bex === y
.Actual behavior:
x.id
triggersx
is possibly undefined.The text was updated successfully, but these errors were encountered: