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) {
|
export default function transpileEnum(path, t) {
|
||||||
const { node } = path;
|
const { node } = path;
|
||||||
|
if (node.const) {
|
||||||
|
throw path.buildCodeFrameError("'const' enums are not supported.");
|
||||||
|
}
|
||||||
|
|
||||||
if (node.declare) {
|
if (node.declare) {
|
||||||
path.remove();
|
path.remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.const) {
|
|
||||||
throw path.buildCodeFrameError("'const' enums are not supported.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const name = node.id.name;
|
const name = node.id.name;
|
||||||
const fill = enumFill(path, t, node.id);
|
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