• Error
  • Reported by the type checker

TS2578

Unused '@ts-expect-error' directive.

A // @ts-expect-error comment has no error on the next line to suppress. Remove the comment.

What it means

// @ts-expect-error suppresses the error on the following line, and it is itself an error when that line has no error. That keeps the directive from outliving the problem it was added for.

Example

index.ts
// @ts-expect-error
const n: number = 1;
export {};
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(1,1): error TS2578: Unused '@ts-expect-error' directive.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Delete the directive if the error it covered has been fixed.
  • If you only want to silence a possible error, // @ts-ignore doesn't complain when there is none, but it hides real errors too.