You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert.strictEqual(false, anyArgument) triggers unreachable code error for any code below after the recent @types/node update. This only reproduces with @types/node 10.17.24, 12.12.41, 13.13.8 (published recently).
Note that it only reproduces with false as a value being checked. Replace it with anything else and it will compile.
This does look like it might be a bug in tsc, as while true & false are given a bit of extra special treatment (iirc), it still fails if both parameters are the false literal which doesn't seem right.
However, you can work around it in the meantime by casting false to boolean:
import * as assert from 'assert';
const b = false;
assert.strictEqual(false as boolean, b);
console.log('really unreachable?');
Activity
G-Rath commentedon May 21, 2020
Cross-posting from the DT issue for coverage:
This does look like it might be a bug in tsc, as while
true&falseare given a bit of extra special treatment (iirc), it still fails if both parameters are thefalseliteral which doesn't seem right.However, you can work around it in the meantime by casting false to boolean:
ahejlsberg commentedon Jun 21, 2020
This is a bug in our code reachability analysis. It's a simple fix. Will put up a PR.
ahejlsberg commentedon Jun 21, 2020
Ah, we already have a fix in #38710, but it never got merged. Will do now.