Throw error on TypeScript declare const enum (#11410)
Throw error on `const enum` even if it has `declare`. Resolves: #10785
This commit is contained in:
parent
a34424a894
commit
9b716518ed
@ -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);
|
||||
|
||||
|
||||
1
packages/babel-plugin-transform-typescript/test/fixtures/declarations/const-enum/input.ts
vendored
Normal file
1
packages/babel-plugin-transform-typescript/test/fixtures/declarations/const-enum/input.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare const enum E {}
|
||||
@ -0,0 +1 @@
|
||||
{ "throws": "'const' enums are not supported." }
|
||||
Loading…
x
Reference in New Issue
Block a user