Answers for "How to stop error reporting in TypeScript?"

0

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".
Posted by: Guest on January-17-2022

Code answers related to "TypeScript"

Browse Popular Code Answers by Language