Skip to content

Commit

Permalink
Throw error on TypeScript declare const enum (#11410)
Browse files Browse the repository at this point in the history
Throw error on `const enum` even if it has `declare`.

Resolves: #10785
  • Loading branch information
dosentmatter committed Apr 23, 2020
1 parent a34424a commit 9b71651
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/babel-plugin-transform-typescript/src/enum.js
Expand Up @@ -3,15 +3,15 @@ import { template } from "@babel/core";

export default function transpileEnum(path, t) {
const { node } = path;
if (node.const) {
throw path.buildCodeFrameError("'const' enums are not supported.");
}

if (node.declare) {
path.remove();
return;
}

if (node.const) {
throw path.buildCodeFrameError("'const' enums are not supported.");
}

const name = node.id.name;
const fill = enumFill(path, t, node.id);

Expand Down
@@ -0,0 +1 @@
declare const enum E {}
@@ -0,0 +1 @@
{ "throws": "'const' enums are not supported." }

0 comments on commit 9b71651

Please sign in to comment.