tslint-consistent-codestyle
tslint-consistent-codestyle copied to clipboard
prefer-const-enums: why are exports ignored?
Enums that are exported or available in the global scope are ignored.
In https://github.com/ajafff/tslint-consistent-codestyle/blob/master/docs/prefer-const-enum.md, not sure why this restriction is in place?
I'm guessing it's because library depending on the exported member will not be able to see the enum. In my case I have no enums exported in my public API and would prefer const enums, an option would be good here imo.
Exported enums may be used outside of the library in a dynamic way that is not supported with const enums. That could be configured by introducing a new configuration option.
But unfortunately there is another design limitation. The rule only processes one file at a time. That means it won't find dynamic uses of the enum in other files of your library.
I guess this is doable if type information is available. I'll look into this for one of the next releases.
Hello!
Thank you for this great module.
However, I've installed this module only for prefer-const-enum rule just to find out that it's not actually working. I'm defining all my types in separate or individual files, so all my types including enums are exported and used in other JavaScript modules.
Are you planning to enable support for this use case? Thanks!
+1 also would like to see this