Closed
Description
When I import a module that has an enum and then I pass a string variable as index, with the noImplicitAny flag set to true, I get an error of implicit any in the index signature.
Examples:
This works but it has an unwanted behavior detailed in the comment:
enum Foobar {
"foo",
"bar"
}
var consoleFoobar = (index: string) => {
// output is of type any. It should be number if the index is string and string if the index is number
var output = Foobar[index];
console.log(output);
}
This trows an error:
// a-module.ts
export enum Foobar {
"foo",
"bar"
}
// app.ts
import { Foobar } from "./a-module";
var consoleFoobar = (index: string) => {
var output = Foobar[index]; // Error: Index signature of object type implicitly has an 'any' type.
console.log(output);
}