I'm going through a Pluralsight course on TypeScript and this throws an error, while it is explained to be a valid code in the course.
error TS2322: Type '{ favouriteSport: string; name: string; kids: number; age: number; calcPets: () => number; makeYo...' is not assignable to type 'Person'. Object literal may only specify known properties, and 'favouriteSport' does not exist in type 'Person'.
interface Person{
age: number,
name: string,
kids: number,
calcPets: ()=> number;
makeYounger: (years: number) => void;
greet: (msg: string) => string;
}
var p: Person = {
favouriteSport: "tennis",
name: "Michael",
kids: 4,
age: 44,
calcPets: function(){
return this.kids * 2;
},
makeYounger: function(years: number){
this.age -= years;
},
greet: function(msg: string){
return msg + ', ' + this.name;
}
}