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
Apparently, since 2.9.1, unreachable code is allowed by default, you have to explicitly set allowUnreachableCode to false in tsconfig.json to get the old behavior.
The documentation is still wrong. When the compiler is called in command line mode, unreachable code is not reported at the console unless allowUnreachableCode is explicitly set to false.
see #24261
A note for Visual Studio (vscode) users: it appears that when vscode analyzes TypeScript code, and allowUnreachableCode is unset in tsconfig.json, it follows the documented behavior and assumes the default is false. This can lead you to a bad time when your command-line compiler and Visual Studio disagree on whether unreachable code is allowed.
Picking a value and setting it in tsconfig.json appears to fix the issue.
Activity
Mr-Wallet commentedon Sep 26, 2018
The docs on
--allowUnreachableCodejust cost me half an hour; I hope that PR hasn't stalled, for the sake of others.chdh commentedon May 2, 2019
The documentation is still wrong. When the compiler is called in command line mode, unreachable code is not reported at the console unless
allowUnreachableCodeis explicitly set tofalse.see #24261
fixermark commentedon Jul 29, 2020
A note for Visual Studio (vscode) users: it appears that when vscode analyzes TypeScript code, and
allowUnreachableCodeis unset intsconfig.json, it follows the documented behavior and assumes the default isfalse. This can lead you to a bad time when your command-line compiler and Visual Studio disagree on whether unreachable code is allowed.Picking a value and setting it in
tsconfig.jsonappears to fix the issue.