Skip to content

[@types/node] assert.strictEqual(false, ...) triggers unreachable code error #44944

@alexander-fenster

Description

@alexander-fenster

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 looks to me like a tsc problem rather than types problem (I reported it in microsoft/TypeScript#38699) but the fastest fix would be rolling back the @types/node changes, so I'm duplicating the issue here as well.

TypeScript Version: 3.9.3, also reproduces on 3.8.x

Code

import * as assert from 'assert';

const b = false;
assert.strictEqual(false, b);
console.log('really unreachable?');

Expected behavior: should compile with --allowUnreachableCode false.

Actual behavior:

$ npx tsc --allowUnreachableCode false src/index.ts 
src/index.ts:5:1 - error TS7027: Unreachable code detected.

5 console.log('really unreachable?');
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error.

This looks to be directly caused by recent releases of @types/node with this commit e910379 included.

  • I tried using the @types/xxxx package and had problems.
  • I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • Mention the authors (see Definitions by: in index.d.ts) so they can respond.
    • Authors: @G-Rath as a commit author

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions