I have an enum in typescript which has 20+ fields. I have UI application where user can put information in some freetext (for example let's say the color the person likes). My requirement is to take this color information and call the midtier service. The midtier service has Color defined as Enum which is kept in sync with UI enum definition. I need to convert the user input text to enum (in front end side) as there are compilation issues being thrown during build. I am not finding a way to perform the conversion (for example from the user input string to a specific enum element). Any pointers will be helpful.
Here is the sample code
export enum Color {
green='green',
orange='orange',
yellow = 'yellow'
......
and so on
}
User gives the input as green (which is a string). When I am calling the service on midtier, it expects an enum.
Regards
yourEnum[ thatString ]? Hard to tell without a minimal reproducible example