How do I transform a string to an enum type in Typescript. I want to return a list of all elements of my enum by passing the name of an enum with a string
For example:
enum Toto {A, B, C, D}
enum Autre {F, G, H}
...
...
extract(enumName: string) {
// todo
return Object.keys(definition)
.map(key => ({ value: definition[key], title: key }));
}
definition will be one of the Enum.
For instance, if I run extract('toto'), the function must find Toto and inject it into Object.key and return [{A,A},{B,B}, {C,C}, {D,D}]
The issue is I cannot find my enum from my string.
Thank you for your help
definitionin your code, first of all?