TS2578: Unused '@ts-expect-error' directive TypeScript Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

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

A // @ts-expect-error comment suppresses nothing because the next line no longer has an error.

Exact message you may see error TS2578: Unused '@ts-expect-error' directive.Unused '@ts-expect-error' directive. ts(2578)TS2578 Unused @ts-expect-error directive
Seen on: TypeScript

Meaning

Remove the directive (the code is fine now — often after a library/type fix), or move it to the right line. @ts-expect-error is stricter than @ts-ignore by design. Keep it for tests that deliberately check type errors.

Common causes

  • The error was fixed (types updated)
  • Comment on the wrong line (must be directly above)
  • Multi-line expressions shift the error line
  • Different TypeScript version behaviour
  • Conditional types resolving differently

⚡ Quick fix

  1. Delete the directive if there's no error
  2. Move it directly above the offending line
  3. Use @ts-ignore only if the error is intermittent (prefer expect-error)

Detailed fix by platform

TypeScript

  1. typescript
    // @ts-expect-error: intentionally wrong type in test
    foo("123");

How to diagnose

  1. Error — Still present?
  2. Placement — Directly above?
  3. Version — Changed?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

Cannot find module './App.vue' or its corresponding type declarations — TypeScript: error TS2307: Cannot find module './App.vue' or its corresponding type declarations. (Vue)Cannot find module '.…TS1005: ';' expected / ',' expected (syntax error) — TypeScript: error TS1005: ';' expected. (TypeScript)TS1005: ';' expected …TS1128: Declaration or statement expected — TypeScript: error TS1128: Declaration or statement expected. (TypeScript)TS1128: Declaration o…TS1192: Module has no default export — TypeScript: error TS1192: Module '"./utils"' has no default export. (TypeScript)TS1192: Module has no…TS1208: File cannot be compiled under '--isolatedModules' because it is considered a global script file — TypeScript: error TS1208: 'index.ts' cannot be compiled under '--isolatedModules' because it is considered a global script file. Add an import, export, or an empty 'export {}' statement (TypeScript)TS1208: File cannot b…TS2322 — TS2322: Type 'X' is not assignable to type 'Y' (TypeScript)TS2322TS2345 — TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. (Node.js)TS2345TS6133: 'x' is declared but its value is never read — TypeScript: error TS6133: 'x' is declared but its value is never read. (TypeScript)TS6133: 'x' is declar…TS2578: U…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.