TSConfig

allowUnreachableCode

When:

  • undefined (default) provide suggestions as warnings to editors
  • true unreachable code is ignored
  • false raises compiler errors about unreachable code

These warnings are only about code which is provably unreachable due to the use of JavaScript syntax, for example:

ts
function fn(n: number) {
if (n > 5) {
return true;
} else {
return false;
}
return true;
}

With "allowUnreachableCode": false:

ts
function fn(n: number) {
if (n > 5) {
return true;
} else {
return false;
}
return true;
Unreachable code detected.7027Unreachable code detected.
}
Try

This does not affect errors on the basis of code which appears to be unreachable due to type analysis.