Do not short-circuit module visibility calculation when alias visibility is requested (#36339)

This commit is contained in:
Wesley Wigham
2020-01-22 14:49:29 -08:00
committed by GitHub
parent eac2180e40
commit 75f88eee48
5 changed files with 162 additions and 0 deletions

View File

@@ -3569,6 +3569,7 @@ namespace ts {
if (!length(symbols)) return;
let hadAccessibleChain: Symbol | undefined;
let earlyModuleBail = false;
for (const symbol of symbols!) {
// Symbol is accessible if it by itself is accessible
const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/ false);
@@ -3581,6 +3582,14 @@ namespace ts {
}
else {
if (some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
if (shouldComputeAliasesToMakeVisible) {
earlyModuleBail = true;
// Generally speaking, we want to use the aliases that already exist to refer to a module, if present
// In order to do so, we need to find those aliases in order to retain them in declaration emit; so
// if we are in declaration emit, we cannot use the fast path for module visibility until we've exhausted
// all other visibility options (in order to capture the possible aliases used to reference the module)
continue;
}
// Any meaning of a module symbol is always accessible via an `import` type
return {
accessibility: SymbolAccessibility.Accessible
@@ -3617,6 +3626,12 @@ namespace ts {
}
}
if (earlyModuleBail) {
return {
accessibility: SymbolAccessibility.Accessible
};
}
if (hadAccessibleChain) {
return {
accessibility: SymbolAccessibility.NotAccessible,