I have a class like this:
interface UserProps {
name: string
age: number
}
export class User {
constructor(private data: UserProps) {}
get(propName: string): number | string {
return this.data[propName]
}
}
and I don't know why I get this error: "Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'UserProps'.
No index signature with a parameter of type 'string' was found on type 'UserProps'"
any advice?