From 24fe1f0dd5183125fb23f056b73fd075bdd7a72c Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Fri, 16 Sep 2022 17:59:14 +0800 Subject: [PATCH] fix --- .../src/plugins/typescript/scope.ts | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/babel-parser/src/plugins/typescript/scope.ts b/packages/babel-parser/src/plugins/typescript/scope.ts index cef20424ed38..9e08e2c1376e 100644 --- a/packages/babel-parser/src/plugins/typescript/scope.ts +++ b/packages/babel-parser/src/plugins/typescript/scope.ts @@ -64,9 +64,22 @@ export default class TypeScriptScopeHandler extends ScopeHandler 1) { + for (let i = 0; i < len - 1; i++) { + if (this.importsStack[i].has(name)) return true; + } + } + return false; + } + declareName(name: string, bindingType: BindingTypes, loc: Position) { if (bindingType & BIND_FLAGS_TS_IMPORT) { - if (this.importsStack[this.importsStack.length - 1].has(name)) { + if (this.hasImport(name, true)) { this.parser.raise(Errors.VarRedeclaration, { at: loc, identifierName: name, @@ -132,19 +145,12 @@ export default class TypeScriptScopeHandler extends ScopeHandler