@@ -3935,12 +3935,12 @@ namespace ts {
39353935 return typeCopy;
39363936 }
39373937
3938- function forEachSymbolTableInScope<T>(enclosingDeclaration: Node | undefined, callback: (symbolTable: SymbolTable) => T): T {
3938+ function forEachSymbolTableInScope<T>(enclosingDeclaration: Node | undefined, callback: (symbolTable: SymbolTable, ignoreQualification?: boolean, isLocalNameLookup?: boolean ) => T): T {
39393939 let result: T;
39403940 for (let location = enclosingDeclaration; location; location = location.parent) {
39413941 // Locals of a source file are not in scope (because they get merged into the global symbol table)
39423942 if (location.locals && !isGlobalSourceFile(location)) {
3943- if (result = callback(location.locals)) {
3943+ if (result = callback(location.locals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true )) {
39443944 return result;
39453945 }
39463946 }
@@ -3955,7 +3955,7 @@ namespace ts {
39553955 // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten
39563956 // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred
39573957 // to one another anyway)
3958- if (result = callback(sym?.exports || emptySymbols)) {
3958+ if (result = callback(sym?.exports || emptySymbols, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true )) {
39593959 return result;
39603960 }
39613961 break;
@@ -3983,7 +3983,7 @@ namespace ts {
39833983 }
39843984 }
39853985
3986- return callback(globals);
3986+ return callback(globals, /*ignoreQualification*/ undefined, /*isLocalNameLookup*/ true );
39873987 }
39883988
39893989 function getQualifiedLeftMeaning(rightMeaning: SymbolFlags) {
@@ -4006,12 +4006,12 @@ namespace ts {
40064006 /**
40074007 * @param {ignoreQualification} boolean Set when a symbol is being looked for through the exports of another symbol (meaning we have a route to qualify it already)
40084008 */
4009- function getAccessibleSymbolChainFromSymbolTable(symbols: SymbolTable, ignoreQualification?: boolean): Symbol[] | undefined {
4009+ function getAccessibleSymbolChainFromSymbolTable(symbols: SymbolTable, ignoreQualification?: boolean, isLocalNameLookup?: boolean ): Symbol[] | undefined {
40104010 if (!pushIfUnique(visitedSymbolTables!, symbols)) {
40114011 return undefined;
40124012 }
40134013
4014- const result = trySymbolTable(symbols, ignoreQualification);
4014+ const result = trySymbolTable(symbols, ignoreQualification, isLocalNameLookup );
40154015 visitedSymbolTables!.pop();
40164016 return result;
40174017 }
@@ -4032,7 +4032,7 @@ namespace ts {
40324032 (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning));
40334033 }
40344034
4035- function trySymbolTable(symbols: SymbolTable, ignoreQualification: boolean | undefined): Symbol[] | undefined {
4035+ function trySymbolTable(symbols: SymbolTable, ignoreQualification: boolean | undefined, isLocalNameLookup: boolean | undefined ): Symbol[] | undefined {
40364036 // If symbol is directly available by its name in the symbol table
40374037 if (isAccessible(symbols.get(symbol!.escapedName)!, /*resolvedAliasSymbol*/ undefined, ignoreQualification)) {
40384038 return [symbol!];
@@ -4046,6 +4046,8 @@ namespace ts {
40464046 && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && isExternalModule(getSourceFileOfNode(enclosingDeclaration)))
40474047 // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name
40484048 && (!useOnlyExternalAliasing || some(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration))
4049+ // If we're looking up a local name to reference directly, omit namespace reexports, otherwise when we're trawling through an export list to make a dotted name, we can keep it
4050+ && (isLocalNameLookup ? !some(symbolFromSymbolTable.declarations, isNamespaceReexportDeclaration) : true)
40494051 // While exports are generally considered to be in scope, export-specifier declared symbols are _not_
40504052 // See similar comment in `resolveName` for details
40514053 && (ignoreQualification || !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier))
@@ -4160,7 +4162,7 @@ namespace ts {
41604162 return hasAccessibleDeclarations;
41614163 }
41624164 }
4163- else if (allowModules) {
4165+ if (allowModules) {
41644166 if (some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
41654167 if (shouldComputeAliasesToMakeVisible) {
41664168 earlyModuleBail = true;
0 commit comments