TSConfig
allowUnreachableCode
When:
undefined
(default) provide suggestions as warnings to editorstrue
unreachable code is ignoredfalse
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
:
tsTry
functionfn (n : number) {if (n > 5) {return true;} else {return false;}return true;Unreachable code detected.7027Unreachable code detected.}
This does not affect errors on the basis of code which appears to be unreachable due to type analysis.