-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
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()); // 100is there any reason why in the else block we are failing to narrow the type to Foo?
Metadata
Metadata
Assignees
Labels
Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript