Compilation warning "Error inaccessible code" instead of an error in TypeScript?

In Typescript, when there is unreachable code, the compiler generates a default error:

error TS7027: Unreachable code detected.

I can avoid this by using the compiler option allowUnreachableCodebefore true, but can I somehow change it to a warning?

I would still rather know about unreachable code. During development and debugging, I sometimes use if (false)to temporarily remove some functions, which is better than commenting out the code, especially when the code itself contains comments.

In C #, unreachable code generates a warning (which I can consider as an error with another option), which seems to me the best way to handle this.

+6
source share
2

"", ; , "", "". Github , , . , .

+1

(, , , ),

if( <any>false ) {
  // unused code goes here
}

TypeScript ECMAScript .

,

if( 0 ) {
  // unused code goes here
}

TypeScript, - " " tslint.

+1

All Articles