In my problem, I am extracting keys of an enum using Object.keys as follows:
const enum Foo {
FOO = 'foo',
BAR = 'bar'
}
const keys = Object.keys(Foo)
When I then try to use the same keys to point at values from Foo enum, I am getting the following error:
Foo[keys[0]] // Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'typeof Foo'.
What kind of type should I cast keys to in order for the above to work?



Fooat runtime. Please provide a minimal reproducible example that clearly demonstrates the issue you are facing. Ideally someone could paste the code into a standalone IDE like The TypeScript Playground (link here!) and immediately get to work solving the problem without first needing to re-create it.