TS2739

error TS2739: Type ‘{}‘ is missing the following properties from type ‘Person‘: age, name

Broken Code ❌

1
2
3
4
5
6
type Person = {
age: number;
name: string;
}

const benny: Person = {};

Fixed Code ✔️

The object doesn’t have any properties, so it cannot be assigned to the type of Person. We have to add the missing properties to fix this error:

1
2
3
4
5
6
7
8
9
type Person = {
age: number;
name: string;
}

const benny: Person = {
age: 34,
name: 'Benny'
};

Video Tutorial