I am working with an enum called ABC:
enum ABC {
A = 'a',
B = 'b',
C = 'c',
}
In addition, I have a method named doSomething:
doSomething(enum: ABC) {
switch(enum) {
case A :
console.log(A);
break;
case B :
console.log(B);
break;
case C :
console.log(C);
break;
}
}
I am wondering if it is possible to invoke the method doSomething(enum: ABC)
using strings like 'a', 'b', 'c.
For example, I would like to achieve something similar to this:
const enumA: ABC = ABC.getByValue('a'); // this would be equivalent to ABC.A
doSomething(enumA);
Is this type of functionality achievable in TypeScript?