Member does not match the base
Property 'm' in type 'K' is not assignable to the same property in base type 'I'.…The compiler’s own words. Not translated — this is the string you pasted into a search box.
The member exists, which is why this is not TS2420 — but its type is not compatible with the one the base declared.
Reproduction
interface I { m(): string } class K implements I { m(): number { return 1 } }
The build asserts this emits exactly this code.
Why the compiler says this
A subtype may promise *more* than its base, never less or different. Returning a narrower type than the base declared is fine; returning an unrelated one breaks every caller that was written against the interface. The nested detail under this message is where the real information is — it names the two member types and which direction the assignment failed in.
Fixes
- 01
interface I { m(): string } class K implements I { m(): string { return 'ok' } }
Match the base.
- 02
interface I { m(): string | number } class K implements I { m(): number { return 1 } }
Or widen the base so the narrower member is a legal specialisation. Now `number` is assignable to what `I` promised, and callers were warned to expect either.
Takeaway
Substitutability runs one way. Anywhere the base is expected the subtype must fit, and "fits" is decided by the same assignability rules as everything else.