Closed
Description
TypeScript Version: nightly (2.1.0-dev.20161006)
Code
type A_or_C_Child = A | C_Child;
interface A {
a: string;
}
interface B {
b: string;
}
interface C {
c: string;
}
interface C_Child extends A, C {
extra: string;
}
declare function isA(it: any): it is A;
declare function isB(it: any): it is B;
declare function isC(it: any): it is C;
declare function isA_or_C_Child(it: any): it is A_or_C_Child;
let item: any;
if (isA_or_C_Child(item) && !isC(item) && isB(item)) {
item; // inferred as A & B
}
if (isA_or_C_Child(item) && isB(item) && !isC(item)) {
item; // inferred as A_or_C_Child & B
}
Expected behavior:
Within the the last two if statements, item should be inferred to be the same type, as both if statements use the same type guards &&
ed together.
Actual behavior:
item
is (correctly, I think) inferred as A & B
in the first if, but as A_or_C_Child & B
in the second.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment