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