Closed
Description
Hi,
TS Version: 1.4
In the following:
class Bar {
bar ='bar';
}
class Foo {
foo = 100;
}
function f1(x: Bar|Foo) {
if(x instanceof Bar){
console.log(x.bar);
}
else {
console.log(x.foo); // Error: inferred as Bar|Foo
}
}
f1(new Bar()); // bar
f1(new Foo()); // 100
is there any reason why in the else
block we are failing to narrow the type to Foo
?