TypeScript: error TS2578: Unused '@ts-expect-error' directive.
A // @ts-expect-error comment suppresses nothing because the next line no longer has an error.
error TS2578: Unused '@ts-expect-error' directive.Unused '@ts-expect-error' directive. ts(2578)TS2578 Unused @ts-expect-error directive 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
- Delete the directive if there's no error
- Move it directly above the offending line
- Use
@ts-ignoreonly if the error is intermittent (prefer expect-error)
Detailed fix by platform
TypeScript
- typescript
// @ts-expect-error: intentionally wrong type in test foo("123");
How to diagnose
- Error — Still present?
- Placement — Directly above?
- 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:
Similar errors
- Cannot find module './App.vue' or its corresponding type declarations TypeScript: error TS2307: Cannot find module './App.vue' or its corresponding type declarations.
- TS1005: ';' expected / ',' expected (syntax error) TypeScript: error TS1005: ';' expected.
- TS1128: Declaration or statement expected TypeScript: error TS1128: Declaration or statement expected.
Most viewed in TypeScript
- TS2564 TS2564: Property 'x' has no initializer and is not definitely assigned in the constructor
- TS7006 TS7006: Parameter 'x' implicitly has an 'any' type
- TS2366: Function lacks ending return statement TypeScript: error TS2366: Function lacks ending return statement and return type does not include 'undefined'.
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 5 Nov 2026