Skip to content

    ↑↓ move · ⏎ open · esc close

    TS2578

    The error you expected is gone

    Unused '@ts-expect-error' directive.

    The compiler’s own words. Not translated — this is the string you pasted into a search box.

    You told the compiler the next line would fail, and it did not. That is good news reported as an error, and it is exactly what the directive is for.

    Reproduction

    // @ts-expect-error
    const fine: number = 1

    The build asserts this emits exactly this code.

    Why the compiler says this

    This is the whole difference between `@ts-expect-error` and `@ts-ignore`. Both suppress the next line, but only one of them complains when the suppression stops being needed. A codebase full of `@ts-ignore` accumulates silence that nobody ever revisits; a codebase using `@ts-expect-error` gets told the moment a workaround has outlived the bug it was working around.

    Fixes

    1. 01
      const fine: number = 1

      Delete the directive. The problem it was covering has been fixed — usually by a dependency upgrade or by someone improving the types upstream.

    2. 02
      // @ts-expect-error
      const broken: number = 'not a number'

      Or, if the directive drifted onto the wrong line during an edit, put it back above the line that really does fail.

    Takeaway

    Prefer `@ts-expect-error` to `@ts-ignore` everywhere. It is the only suppression that expires on its own.

    Errors