Comment directive

// @ts-nocheck

  • Applies to the whole file
  • Since TypeScript 2.3

// @ts-nocheck is the opposite of // @ts-check: written before the first line of code, it stops error reporting for that one file while checkJs keeps checking every other file. It arrived for JavaScript files with TypeScript 2.3, and .ts files have honored it since 3.7.

The file is still part of the program. Its JSDoc still types what it exports, so a file that imports total from it is checked against those types; only the mistakes inside the skipped file go unreported, as the two examples show.

At a glance

Write // @ts-nocheck
Applies to The whole file, when it comes before the first line of code
With checkJs on Skips this file: no errors are reported in it, but its types still reach the files that import it
With checkJs off Nothing: the file is not checked anyway

Examples

legacy.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
// @ts-nocheck
/**
 * @param {{ price: number }[]} items
 * @returns {number}
 */
export function total(items) {
  return items.reduce((sum, item) => sum + item.price, 0);
}

/** @param {string} name */
export function shout(name) {
  return name.toUppercase();
}
// @ts-nocheck: the mistake in this file is not reported.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": [
    "*.js"
  ]
}
legacy.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: legacy.js(12,15): error TS2551: Property 'toUppercase' does not exist on type 'string'. Did you mean 'toUpperCase'? 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. legacy.js(12,15): error TS2551: Property 'toUppercase' does not exist on type 'string'. Did you mean 'toUpperCase'? 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. legacy.js(12,15): error TS2551: Property 'toUppercase' does not exist on type 'string'. Did you mean 'toUpperCase'? checked 21 October 2026
/**
 * @param {{ price: number }[]} items
 * @returns {number}
 */
export function total(items) {
  return items.reduce((sum, item) => sum + item.price, 0);
}

/** @param {string} name */
export function shout(name) {
  return name.toUppercase();error TS2551: Property 'toUppercase' does not exist on type 'string'. Did you mean 'toUpperCase'?
}
The same file without it: checked like the rest.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": [
    "*.js"
  ]
}

Using it during a migration

Turn on checkJs for the whole project, add // @ts-nocheck to the files that report too much, and remove the comments one file at a time. New files are checked from the start, and grep -l "@ts-nocheck" lists what is left.

Gotchas

  • If a file has both // @ts-check and // @ts-nocheck, the later of the two wins.
  • Like // @ts-check, it counts only before the first line of code.

Sources

Last reviewed 20 October 2026.