diff --git a/packages/babel-plugin-transform-typescript/src/enum.js b/packages/babel-plugin-transform-typescript/src/enum.js index 3b604e2e8fab..808f2fcf499f 100644 --- a/packages/babel-plugin-transform-typescript/src/enum.js +++ b/packages/babel-plugin-transform-typescript/src/enum.js @@ -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); diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/declarations/const-enum/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/declarations/const-enum/input.ts new file mode 100644 index 000000000000..4a3fc75be0db --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/declarations/const-enum/input.ts @@ -0,0 +1 @@ +declare const enum E {} diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/declarations/const-enum/options.json b/packages/babel-plugin-transform-typescript/test/fixtures/declarations/const-enum/options.json new file mode 100644 index 000000000000..26f55acbbd35 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/declarations/const-enum/options.json @@ -0,0 +1 @@ +{ "throws": "'const' enums are not supported." }