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

fix(jsii): prohibit exported const enums #372

Merged
merged 1 commit into from
Mar 7, 2019

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Mar 7, 2019

'const enums' are inlined at the usage site by TypeScript and so the
generated type will not be in the JavaScript source code in the
assembly, even though the declaration will be there.

This leads to "symbol not found" errors upon trying to load it.

Ref: https://www.typescriptlang.org/docs/handbook/enums.html#const-enums
Related: aws/aws-cdk#1969

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

'const enums' are inlined at the usage site by TypeScript and so the
generated type will not be in the JavaScript source code in the
assembly, even though the declaration will be there.

This leads to "symbol not found" errors upon trying to load it.

https://www.typescriptlang.org/docs/handbook/enums.html#const-enums

Fixes aws/aws-cdk#1969
@rix0rrr rix0rrr requested a review from a team as a code owner March 7, 2019 08:25
this._diagnostic(decl,
ts.DiagnosticCategory.Error,
`Exported enum cannot be declared 'const'`);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we return from there? So we don't include it in the .jsii assembly we'd create?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

@RomainMuller RomainMuller merged commit 5a94825 into master Mar 7, 2019
@RomainMuller RomainMuller deleted the huijbers/no-const-enum branch March 7, 2019 08:37
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

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

Successfully merging this pull request may close these issues.

3 participants