In certain cases I'd like to widen the type of an object which is casted literally (using "as const"), so it's properties will be inferred as strings or numbers, and not literally.
Imagine I have the following type
const obj = [
{
type:"student",
name:"Yossi"
},
{
type: "Teacher",
name: "Lili"
}
] as const
type Person = typeof obj [number]
I'd like the type of obj to be inferred literally, but Person to be Wider, so it's type and name are strings. Is there a generic which can allow the following:
type Person = Widen<typeof obj [number]>