I’m following the exercise to add a type to the array below but I get a complaint in Typescript with the following:
“Type ‘{ name: string; age: number; occupation: string; }’ is missing the following properties from type ‘User’: name, age”
What am I doing wrong?
type User = {
name: string
age: number
occupation?: string
}
let users: User = [
{ name: 'John', age: 25, occupation: 'gardener' },
{ name: 'Mary', age: 31, occupation: 'teacher' },
]