TypeScript Version: nightly (2.0.0-dev.201xxxxx)
Code
class SomeClass {
constructor(public id: number){}
}
class SomeOtherClass {
constructor(public name: string){}
}
type SomeUnionType = SomeClass | SomeOtherClass;
function buggyFunction(aArray: string[], bug: SomeUnionType): void {
if (bug instanceof SomeClass) {
console.log(bug.id);
return;
}
if (bug instanceof SomeOtherClass) {
aArray.map((a) => a = bug.name());
return;
}
return;
}
Expected behavior:
Typescript should know that bug is of the type SomeOtherClass inside of the map function.
Actual behavior:
Property 'name' does not exist on type SomeClass | SomeOtherClass.
TypeScript Version: nightly (2.0.0-dev.201xxxxx)
Code
Expected behavior:
Typescript should know that
bugis of the type SomeOtherClass inside of the map function.Actual behavior:
Property 'name' does not exist on type SomeClass | SomeOtherClass.