// @ts-ignore on its own line silences every error on the line after it. It came with checkJs for JavaScript files, with TypeScript 2.3 (TypeScript's release notes date .ts support to 2.6).
The trouble is "every error, now and later": once the original problem is fixed, the comment stays and silently swallows the next mistake on that line, as the example shows. // @ts-expect-error does the same job and is reported once it has nothing to silence, so it is almost always the better choice.
At a glance
| Write | // @ts-ignore |
|---|---|
| Applies to | The line after the comment |
| With checkJs on | Silences every error on the next line |
| With checkJs off | Nothing, unless the file starts with // @ts-check |
Examples
/** @param {number} cents */
function formatPrice(cents) {
return `$${(cents / 100).toFixed(2)}`;
}
// The old API passed strings; silenced until it is fixed.
// @ts-ignore
console.log(formatPrice("1999"));
// Months later the same line was edited, and the typo is silenced too.
// @ts-ignore
console.log(fromatPrice(1999));jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": [
"*.js"
]
} When @ts-ignore is still the right comment
When the same line errors under one setup and not another, for example code checked by two TypeScript versions or two configs. // @ts-expect-error would be reported as unused in the setup without the error; // @ts-ignore is quiet in both.
Gotchas
- It covers one line only: the line right after the comment. An error that TypeScript reports on a later line of a multi-line statement is not silenced.
- Anything after
@ts-ignoreon the same comment line is free text, so// @ts-ignore: legacy APIdocuments why.
Sources
- JS Projects Utilizing TypeScript · TypeScript handbook
- TypeScript 2.3 release notes · TypeScript handbook
- TypeScript 2.6 release notes · TypeScript handbook
Last reviewed 20 October 2026.