-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
This could be a dup of #14748; they seem related
TypeScript Version: 2.7.0-dev.20171102
Code
See in playground
class A {
name: string;
}
class B {
age: number;
}
let x: A | B;
if (x instanceof A) {
console.log(x.name); // ok: x has type A
setTimeout(() => {
console.log(x.name); // ** COMPILE ERROR: x has type A | B here
});
} else {
console.log(x.age); // ok: x has type B here
setTimeout(() => {
console.log(x.age); // ** COMPILE ERROR: x has type A | B here
});
}
Expected behavior:
This should compile.
Actual behavior:
It does not compile
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created