export enum MyEnum{
Option1,
Option2,
Option3
}
string selection = 'Option1';
MyEnum[selection]
results in an error:
The type string cannot be assigned to the type MyEnum
On the other hand:
MyEnum['Option1']
works as expected.
I'm looking to utilize MyEnum[selection]
(in a function that returns a MyEnum), with the condition that selection is a dynamically determined value corresponding to one of the valid enum options. How should I approach this?