Typescript: why am i getting a 'property does not exist on type' error?
Example:
interface Person {
name: string;
}
const person: Person = {
name: 'John',
age: 25 // Error: Property 'age' does not exist on type 'Person'.
};
Solution:
interface Person {
name: string;
age: number; // Added 'age' property to the interface
}
const person: Person = {
name: 'John',
age: 25
};
Ensure that all properties of your object match the properties declared in the corresponding type or interface.