Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/babel-plugin-transform-typescript/src/const-enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export default function transpileConstEnum(
),
);

if (path.scope.hasOwnBinding(name)) {
const oldBinding = path.scope.getOwnBinding(name);
path.scope.removeOwnBinding(name);
if (oldBinding?.kind !== "unknown") {
(parentIsExport ? path.parentPath : path).replaceWith(
t.expressionStatement(
t.callExpression(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export { Enum };

const enum Enum {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": [["transform-typescript"]],
"sourceType": "module",
"validateLogs": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { Enum };
var Enum = /*#__PURE__*/function (Enum) {
return Enum;
}(Enum || {});
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
The exported identifier "WhitespaceFlag" is not declared in Babel's scope tracker
as a JavaScript value binding, and "@babel/plugin-transform-typescript"
never encountered it as a TypeScript type declaration.
It will be treated as a JavaScript value.

This problem is likely caused by another plugin injecting
"WhitespaceFlag" without registering it in the scope tracker. If you are the author
of that plugin, please use "scope.registerDeclaration(declarationPath)".
The exported identifier "WhitespaceFlag" is not declared in Babel's scope tracker
as a JavaScript value binding, and "@babel/plugin-transform-typescript"
never encountered it as a TypeScript type declaration.
It will be treated as a JavaScript value.

This problem is likely caused by another plugin injecting
"WhitespaceFlag" without registering it in the scope tracker. If you are the author
of that plugin, please use "scope.registerDeclaration(declarationPath)".
6 changes: 6 additions & 0 deletions packages/babel-traverse/src/scope/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,12 @@ class Scope {
return;
}

if (path.isTSEnumDeclaration() && !path.node.declare) {
const id = path.get("id");
this.registerBinding(kind, id, path);
return;
}

const parent = this.getProgramParent();
const ids = path.getOuterBindingIdentifiers(true);

Expand Down
Loading