Type guard failures that become an intersection type #9859
Closed
Description
TypeScript Version: 2.0.0
Code
class A<T> {
private _: T;
}
class B<T> {
private _: T;
}
function f() {
var o: A<void> | B<void> = new B<void>();
if (o instanceof A) return o; // B<void> & A<any>, should be A<void>
}
Expected behavior:
A type of o
narrowed by type guard is A<void>
.
Actual behavior:
A type of o
narrowed by type guard is B<void> & A<any>
.