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:
Kevin Lau 2020-04-23 02:27:19 -07:00 committed by GitHub
parent a34424a894
commit 9b716518ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -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);

View File

@ -0,0 +1 @@
declare const enum E {}

View File

@ -0,0 +1 @@
{ "throws": "'const' enums are not supported." }