TS2415
TypeScriptERRORNotableClassesHIGH confidence

Class incorrectly implements interface

What this means

A class that claims to implement an interface is missing one or more of the properties or methods required by that interface.

Why it happens
  1. 1Forgetting to implement a method defined in the interface.
  2. 2A typo in the name of an implemented property or method.
  3. 3The signature of the implemented method does not match the signature in the interface (e.g., different parameters or return type).
How to reproduce

A class implements an interface but is missing a required method.

trigger — this will error
trigger — this will error
interface Person {
  name: string;
  greet(): void;
}
class Employee implements Person {
  name: string = "John";
  // Missing greet() method
}

expected output

error TS2415: Class 'Employee' incorrectly implements interface 'Person'. Property 'greet' is missing in type 'Employee' but required in type 'Person'.

Fix 1

Implement the missing member

WHEN A required property or method is not present.

Implement the missing member
interface Person {
  name: string;
  greet(): void;
}
class Employee implements Person {
  name: string = "John";
  greet() {
    console.log("Hello");
  }
}

Why this works

Adding the missing members to the class fulfills the interface contract.

Fix 2

Correct the member signature

WHEN The implementation does not match the interface definition.

Correct the member signature
interface Person {
  name: string;
  greet(message: string): void;
}
class Employee implements Person {
  name: string = "John";
  greet(message: string) {
    console.log(message);
  }
}

Why this works

Aligning the method's parameters and return type with the interface.

What not to do

Remove the 'implements' clause

This silences the error but loses the explicit contract that ensures the class adheres to the interface's shape.

Sources
Official documentation ↗

microsoft/TypeScript src/compiler/diagnosticMessages.json

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All TypeScript errors