Can I fetch the 'key' | 'anotherKey' type from this object?
interface MY_OBJECT_INTERFACE {
[key: string]: string
}
const MY_OBJECT: MY_OBJECT_INTERFACE = {
'key': 'key val',
'anotherKey': 'anotherKey val',
};
The expression "keyof typeof MY_OBJECT" is not working for me. Is there a different way to achieve this?
For more insights, you can refer to this related question: How to extract exact union type from object key strings in typescript?