Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer-const-enums: why are exports ignored? #67

Open
Tyriar opened this issue Apr 24, 2018 · 4 comments
Open

prefer-const-enums: why are exports ignored? #67

Tyriar opened this issue Apr 24, 2018 · 4 comments

Comments

@Tyriar
Copy link

Tyriar commented Apr 24, 2018

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?

@Tyriar
Copy link
Author

Tyriar commented Apr 24, 2018

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.

@ajafff
Copy link
Owner

ajafff commented Apr 24, 2018

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.

@slavafomin
Copy link

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!

@wh1t3cAt1k
Copy link

+1 also would like to see this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants