Skip to content

Commit

Permalink
Merge branch 'master' into dstufft/python-support
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft committed Mar 11, 2019
2 parents 61ff7c1 + 5a94825 commit 5c59915
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/jsii/lib/assembler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,15 @@ export class Assembler implements Emitter {
LOG.trace(`Processing enum: ${colors.gray(namespace.join('.'))}.${colors.cyan(type.symbol.name)}`);
}

const decl = type.symbol.valueDeclaration;
const flags = ts.getCombinedModifierFlags(decl);
// tslint:disable-next-line:no-bitwise
if (flags & ts.ModifierFlags.Const) {
this._diagnostic(decl,
ts.DiagnosticCategory.Error,
`Exported enum cannot be declared 'const'`);
}

const jsiiType: spec.EnumType = {
assembly: this.projectInfo.name,
fqn: `${[this.projectInfo.name, ...namespace].join('.')}.${type.symbol.name}`,
Expand Down
8 changes: 8 additions & 0 deletions packages/jsii/test/negatives/neg.const-enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
///!MATCH_ERROR: Exported enum cannot be declared 'const'

export const enum NotAllowed {
ThisEnum,
GetsInlined,
AndSoItGetsLost,
ForJsii
}

0 comments on commit 5c59915

Please sign in to comment.