In the following Typescript code, the compiler says that the doit property does not exist in the type 'never'. Could this be a compiler error?
class X { public foo(): void { if (this instanceof Y) { } else { this.doit(); } } private doit(): void { } } class Y extends X { }
I found the following workaround:
const temp = (this instanceof Y); if (temp) { } else { this.doit(); }
The compiler has no problems with this equivalent code, which again makes me suspect that there is a compiler error.
source share