You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
enumFoobar{"foo","bar"}varconsoleFoobar=(index: string)=>{// output is of type any. It should be number if the index is string and string if the index is numbervaroutput=Foobar[index];console.log(output);}
This trows an error:
// a-module.tsexportenumFoobar{"foo","bar"}// app.tsimport{Foobar}from"./a-module";varconsoleFoobar=(index: string)=>{varoutput=Foobar[index];// Error: Index signature of object type implicitly has an 'any' type.console.log(output);}
The text was updated successfully, but these errors were encountered:
I don't want to suppress the implicit any errors (they are useful), the thing is that enum is trowing errors and it shuldn't.
Let's say I have an enum like this: enum EnumExample { "value" }. When I write EnumExample[0] I should get a string ("value" in this case) or undefined, and when I write EnumExample["value"] I should get a number (0 in this case) or undefined. The bug is that I get an any if the enum is in the same file, and if I load the enum from a module, It trows an index error (error that doesn't trow if is in the same file).
@lucasmciruzzi with the latest bits in master I see the same behavior in both scenarios (the single file and multi file case). The type of output is any and no errors are reported.
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:
This trows an error:
The text was updated successfully, but these errors were encountered: