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

TS2739: Type ‘string[]’ is missing the following properties from type ‘Promise ‘: then, catch, [Symbol.toStringTag]

Broken Code ❌

1
2
3
function myTest(): Promise<string[]> {
return [''];
}

When your function specifies to return a Promise, you have to ensure that your return value is also wrapped in a Promise:

1
2
3
function myTest(): Promise<string[]> {
return Promise.resolve(['']);
}

Alternatively, you can make use of the async keyword, which will automatically wrap your return value into a Promise:

1
2
3
async function myTest(): Promise<string[]> {
return [''];
}