TS2741
Property 'name' is missing in type '{}' but required in type 'Animal'.
Broken Code ❌
interface Animal {
name: string;
}
const laika: Animal = {};Fixed Code ✔️
Interfaces can be used with classes or plain objects. If we want our object (i.e. laika) to fulfill the contract of Animal, we have to assign all required properties to it:
interface Animal {
name: string;
}
const laika: Animal = {
name: 'Laika',
};