Skip to content

fix(jsii): prohibit exported const enums#372

Merged
RomainMuller merged 1 commit intomasterfrom
huijbers/no-const-enum
Mar 7, 2019
Merged

fix(jsii): prohibit exported const enums#372
RomainMuller merged 1 commit intomasterfrom
huijbers/no-const-enum

Conversation

@rix0rrr
Copy link
Copy Markdown
Collaborator

@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
Copy Markdown
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
Copy Markdown
Collaborator 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
Copy Markdown
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