diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/namespace/declare-global-nested-namespace/input.ts b/packages/babel-plugin-transform-typescript/test/fixtures/namespace/declare-global-nested-namespace/input.ts new file mode 100644 index 000000000000..13f0c52527b4 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/namespace/declare-global-nested-namespace/input.ts @@ -0,0 +1,3 @@ +declare global { namespace globalThis { var i18n: any; } } + +export class i18n {} \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/namespace/declare-global-nested-namespace/output.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/namespace/declare-global-nested-namespace/output.mjs new file mode 100644 index 000000000000..2112258a3b74 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/namespace/declare-global-nested-namespace/output.mjs @@ -0,0 +1 @@ +export class i18n {} diff --git a/packages/babel-traverse/src/scope/index.ts b/packages/babel-traverse/src/scope/index.ts index e2eb17d8f724..100a7df6fa22 100644 --- a/packages/babel-traverse/src/scope/index.ts +++ b/packages/babel-traverse/src/scope/index.ts @@ -745,6 +745,9 @@ export default class Scope { path: NodePath, bindingPath: NodePath = path, ) { + if (path.isVariableDeclarator() && path.scope.path.isTSModuleBlock()) { + return; + } if (!kind) throw new ReferenceError("no `kind`"); if (path.isVariableDeclaration()) {