Sometimes, we want to disable a TypeScript rule for a specific line.
In this article, we’ll look at how to disable a TypeScript rule for a specific line.
How to disable a TypeScript rule for a specific line?
To disable a TypeScript rule for a specific line, we can add a @ts-ignore
comment.
For instance, we write
if (false) {
// @ts-ignore: Unreachable code error
console.log("hello");
}
to add the
// @ts-ignore: Unreachable code error
comment so the TypeScript compiler will ignore the unreachable compiler error.
Conclusion
To disable a TypeScript rule for a specific line, we can add a @ts-ignore
comment.