For various configurations (parameters etc) in my app I like to use objects. The keys of the objects are not strings, but enums.
When the keys are not strings, how can I iterate through the keys and get each key as the proper enum type?
Example:
enum Color {
RED = 1
}
let colorNames: { [key in Color]?: string } = {
[Color.RED]: "red"
}
Object.keys(colorNames).forEach(colorsKeyStr => {
let colorNum: Color = colorsKeyStr // <-- produces error
// What's the proper way to cast a "color" variable to the "Color" enum type?
})