Closed
Description
TypeScript Version: 3.3.3333, 3.4.2, 3.4.5, 3.5.2, 3.6.0-dev.20190704
Search Terms: union, union + object, union + object + bug
Code
interface A {
a: string;
}
interface B {
b: string;
}
const fn = (param: A | B) => param;
const obj = { a: "sdf", c: "sdf" };
fn({ a: "sd" });
fn({ b: "sd" });
fn({ a: "sd", b: "sfg" });
fn({ a: "sdf", c: "sdf" }); // this makes tsc fail
fn(obj); // this does not, but it should
Expected behavior:
tsc
reports two errors, one for the last two lines respectively, as the parameters passed are essentially the same.
Actual behavior:
tsc
only reports the second to last line as error, not the last one (or differently: if I comment the second to last line out, tsc
does not fail, though it should)
Thank you very much!
Metadata
Metadata
Assignees
Labels
No labels