📜  如何停止 TypeScript 中的错误报告? - 打字稿代码示例

📅  最后修改于: 2022-03-11 14:48:33.243000             🧑  作者: Mango

代码示例1
// 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".