Closed
Description
TypeScript Version:
nightly (1.9.0-dev.20160429)
Code
class AAA {
fieldA: string;
}
class BBB {
fieldB: string;
}
class AA {
data: AAA;
}
class BB {
data: BBB;
}
class A {
d: AA;
}
class B {
d: BB;
}
function main(x: A | B) {
for (let i of [1, 1]) {
if (x instanceof A) {
x.d.data.fieldA;
} else if (x instanceof B) {
x.d.data.fieldB; // Not compiles here.
}
}
}
Expected behavior:
To access to the fieldB
field of BBB
class inside of block } else if (x instanceof B) {
Actual behavior:
The compiler raises the follow error: TS2339: Property 'fieldB' does not exist on type 'AAA'.
.
The behavior in the version 1.8.10 is correct.