I am facing a challenge with a file containing a single declaration, which is for an interface:
interface NamedPerson {
firstName: string;
age?: number;
[propName: string]: any;
greet(lastName: string): void;
}
Everything works perfectly as long as the type of [propName: string]: any. However, if I try to change it to number or any other type, I encounter this error:
[ts] Property 'greet' of type '(lastName: string) => void' is not assignable to string index type 'number'.
I specifically want any new unspecified property in an object that uses the NamedPerson interface to only allow values of type number, and nothing else.
Question: What needs to be corrected in the interface definition to meet my requirements?