Skip to content

    ↑↓ move · ⏎ open · esc close

    TS2420

    Class does not implement its interface

    Class 'L' incorrectly implements interface 'J'.…

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

    The class said `implements` and then did not. The detail underneath names exactly what is missing or mismatched.

    Reproduction

    interface J {
      a: number
    }
    
    class L implements J {
    }

    The build asserts this emits exactly this code.

    Why the compiler says this

    `implements` is a check, not an instruction: it does not add anything to the class, it only asks the compiler to confirm the class already satisfies the interface. That is why removing the clause makes the error disappear without making the class any more correct — the interface was never the source of the members, only the specification for them.

    Fixes

    1. 01
      interface J {
        a: number
      }
      
      class L implements J {
        a = 1
      }

      Implement what was promised.

    2. 02
      interface J {
        a?: number
      }
      
      class L implements J {
      }

      Or change the specification, if the member was never really required. Worth doing only when every other implementer can cope with its absence.

    Takeaway

    Deleting `implements` to make this go away removes the only thing that was checking the class. The error is the feature.

    Errors