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?');
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.TypeScript Version: 3.9.3, 3.8.x as well
Search Terms:
strictEqual
error TS7027: Unreachable code detected
Code
Expected behavior: should compile with
--allowUnreachableCode false
.Actual behavior:
Playground Link: N/A because of the specific version of
@types/node
required for a repro.Related Issues: N/A
Background: Here is the commit in
@types/node
that apparently triggers this: DefinitelyTyped/DefinitelyTyped@e910379I reported it there as well in DefinitelyTyped/DefinitelyTyped#44944, but I have an impression the compiler behaves weirdly here.
The text was updated successfully, but these errors were encountered: