When working on interfaces, I often find myself wanting to extend the type Record
in order to define objects with predefined keys and optional values without knowing their names.
For instance:
interface Person extends Record<string, string>{
phonenumber: number,
name: string
}
However, I encountered an error:
Property 'phonenumber' of type 'number' is not assignable to 'string' index type 'string'
I'm unsure how to properly define my interface in a way that allows me to set phonenumber
as a number type while leaving all other fields as string types.