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

Avoid const enum in public API declarations #404

Closed
ajafff opened this issue Sep 3, 2018 · 1 comment
Closed

Avoid const enum in public API declarations #404

ajafff opened this issue Sep 3, 2018 · 1 comment

Comments

@ajafff
Copy link
Member

ajafff commented Sep 3, 2018

const enum in declaration files will cause errors in downstream projects that build with --isolatedModules.

There are two possible solutions:

  • forbid export const enum entirely
  • modify declaration files before publish / after build (like TypeScript does)
    • needs preserveConstEnums

However this is fixed, it needs to be done in upstream dependencies as well (tsutils).

Related discussion: microsoft/TypeScript#20703

@ajafff
Copy link
Member Author

ajafff commented Nov 11, 2018

microsoft/TypeScript#28465 makes it so that there's no error when const enum is merely present in any declaration file. Instead you simply cannot use it.

It still makes sense to avoid const enum in the public API. The inlining of const enum makes it impossible to change its values in a minor or patch release.

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

1 participant