Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

How to stop error reporting in TypeScript?

// this will ignore the code that is one line below
// @ts-ignore
const myAge : number = "25" // no typescript error
const isTrue : boolean = 4; // error

// this will ignore checking the entire file, must be at its top
// @ts-nocheck
const myAge : number = "25" // no error
const isTrue : boolean = 4; // no error

// @ts-expect-error
console.log(47 * "octopus"); //This line will cause an error and TS won't disturb you because you are using "ts-expect-error" for nothing.

// @ts-expect-error
console.log(1 + 1); //However, here the log() function will output 2, which will not throw an error. Thus, there's no purpose of using "ts-expect-error".
 
PREVIOUS NEXT
Tagged: #How #stop #error #reporting
ADD COMMENT
Topic
Name
5+1 =