-
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
3.9 regression: TS2322 error around assignment of an inferred intersection to a union #38542
Comments
Note - I have tried two build a reproduction that does NOT involve importing the separate package - to no avail. Maybe I just didn't try hard enough, or maybe this problem is triggering only when using a locally defined union of types from a dependency? In any case, here are pointers to the relevant types within the
|
Simplified repro: interface AB {
kind: 'a' | 'b';
}
declare class CA { kind: 'a'; a: string; x: number };
declare class CB { kind: 'b'; b: string; y: number };
function bar<T extends CA | CB>(x: T & CA) {
let ab: AB = x; // Error, but shouldn't be
} |
Oh wow so the discriminators were the problem? Swoosh! Well thanks for the prompt response & quick fix!! |
TypeScript Version: 3.9.2, 4.0.0-dev.20200512
Search Terms: TS2322, "is not assignable to type"
Code
Expected behavior:
It should work like it did in TypeScript 3.8
Actual behavior:
Playground Link: I stored my repro at https://github.com/RomainMuller/TypeScript39-Bug (public)
Related Issues: It appears likely related to the breaking change in #37195 (but not certain)
The text was updated successfully, but these errors were encountered: