TS2739
Type '{}' is missing the following properties from type 'Person':
age,name
Broken Code ❌
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:
type Person = {
age: number;
name: string;
};
const benny: Person = {
age: 34,
name: 'Benny',
};Video Tutorial
Type 'string[]' is missing the following properties from type 'Promise ': then, catch, [Symbol.toStringTag]
Broken Code ❌
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:
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:
async function myTest(): Promise<string[]> {
return [''];
}