I have a situation where I need to dynamically use an object property. Typescript doesn't like when I do that..
The situation is similar as the one described above.
How can I type check the Enum[val] or foo variable?
enum Enum {
VAR1 = "A",
VAR2 = "B",
}
const foo = ["VAR1", "VAR2"];
foo.forEach(val => {
const a = Enum[val]; // Typescript doesn't like it (val implicitly has 'any' type...)
const b = Enum[val as any]; // This is "OK", but I use "any", which I'm trying to avoid.
});