Property 'x' does not exist on type 'never'
<p>In the following code Typescript compiler says property 'doit' does not exist on type 'never'. Could this be a compiler bug?</p>

<pre><code>class X {
    public foo(): void {
        if (this instanceof Y) {
        } else {
            this.doit();
        }
    }

    private doit(): void {
    }
}

class Y extends X {
}
</code></pre>

<p>I found the following workaround:         </p>

<pre><code>const temp = (this instanceof Y);
if (temp) {
} else {
    this.doit();
}
</code></pre>

<p>The compiler does not have any issues with this equivalent code, which again leads me to suspect there is a compiler bug here.</p>