-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
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.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue