I am playing around with Typescript a little.
Suppose I have an object such as this
let colors = { RED: "r", GREEN: "g", BLUE: "b" } Now I want to convert this into an enum type
enum Colors = { RED = "r", GREEN = "g", BLUE = "b" } Update:
I want the generated typings for the colors object such that if I add another key to the colors object, It should be included in the typings.
If I do
colors['YELLOW'] = "y" then the generated typings should be
declare enum colors { RED = "r", GREEN = "g", BLUE = "b", YELLOW = "y" } instead, the generate typings are
declare const colors { [x: string]: string } How can I achieve this?
enumto object["red", "blue", "green"]and I would expect it to be converted into aenum Color { red, blue, green }