Is it possible to retrieve the actual keys of an object when utilizing an interface to define the object?
For example:
interface IPerson {
name: string;
}
interface IAddress {
[key: string]: IPerson;
}
const personInAddressObj: IAddress= {
someAddress1: {
name: 'John',
},
someAddress2: {
name: 'Jacob',
}
} as const
type Keys = keyof typeof personInAddressObj;
I would like the type Keys to represent the values "someAddress1 | someAddress2". While I can easily extract the keys when the interface is removed from "personInAddressObj", it seems more challenging to access the actual keys of the object when an interface is involved.