TS2578: Unused '@ts-expect-error' directive

Typescript·Sep 13, 2026·beginner·
Quick answer

You added a `// @ts-expect-error` comment above a line expecting it to suppress a type error, but the line no longer actually produces one — usually because a related fix elsewhere in the code resolved it. Unlike `@ts-ignore`, `@ts-expect-error` is meant to fail loudly once it's no longer needed; just delete the now-unnecessary directive.

What causes this error

@ts-expect-error was designed specifically to avoid the problem with `@ts-ignore`: a silently stale suppression comment sitting above code that no longer has an error, hiding the fact that the situation changed. TypeScript checks that the following line genuinely does produce an error — if it doesn't, the directive itself is flagged as unused.

The Fix

// This used to be a genuine type mismatch, but a dependency update
// or a local fix elsewhere resolved it — the directive is now stale
// @ts-expect-error
const result = someFunction(arg); // no longer actually errors

// Fix — simply remove the now-unnecessary directive
const result = someFunction(arg);

This is generally a welcome signal, not a problem to work around — it means a type issue you were deliberately suppressing has been fixed for real, and you can safely remove the workaround.

Common causes / variations

  • Upgrading a dependency whose types improved, resolving a previously-suppressed error
  • Fixing a type issue elsewhere in the codebase that happened to also resolve this specific line
  • Leftover suppression from an earlier refactor that's no longer applicable

Related errors

See also: TypeScript 6.0 strict mode on by default.

Was this fix helpful?

Comments

Loading comments...

Fix: TS2578 Unused @ts-expect-error directive | BugFixer | BugFixer