I am taking Pluralsight's TypeScript course and this is causing an error while it is being explained as valid code in the course.
TS2322 error: Type '{favoriteSport: string; name: string; children: number; age: number; calcPets :() => number; makeYo ... 'is not assigned to the type' Person '. An object literal can specify only known properties, and "FavoriteSport" does not exist in the "Face" type.
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; } }
source share