- Error
- Reported by the type checker
TS2420
Class '{0}' incorrectly implements interface '{1}'.
A class says it implements an interface but is missing a member or has one with the wrong type. Add or fix the member named in the indented lines.
What it means
implements asks the checker to compare the class's instance type with the interface. A missing member, or one with an incompatible type, is reported on the class name with indented lines that explain which member is wrong.
Example
interface Named {
name: string;
}
export class Robot implements Named {
id = 1;
}
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(4,14): error TS2420: Class 'Robot' incorrectly implements interface 'Named'.
Property 'name' is missing in type 'Robot' but required in type 'Named'.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.
How to fix
- Add the missing members the indented lines list.
- Fix members whose types don't match the interface.
- Remove the
implementsclause if the class isn't meant to satisfy the interface.