Closed
Description
TypeScript Version: 2.0.3
This code compiles in TS 1.8 but not in 2.0.3
Code
class A { }
class B { constructor(public b: number) {} }
function foo(x: A | B): number | boolean {
if (x instanceof A) { return true; }
else if (x instanceof B) { return x.b; }
// ^ Property 'b' does not exist on type 'never'.
};
This error only appears if class A
has no fields or methods,
if I add a field or a method the error disappears (but not constructor).