Comment directive

// @ts-ignore

  • Applies to the next line
  • Since TypeScript 2.3

// @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

main.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
/** @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));
// @ts-ignore silences whatever is on the next line, including a later typo.
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-ignore on the same comment line is free text, so // @ts-ignore: legacy API documents why.

Sources

Last reviewed 20 October 2026.