@@ -2601,10 +2601,10 @@ namespace ts {
2601
2601
const containingFile = getSourceFileOfNode(enclosingDeclaration);
2602
2602
const id = "" + getNodeId(containingFile);
2603
2603
const links = getSymbolLinks(symbol);
2604
- if (links.extendedContainersByFile && links.extendedContainersByFile.has(id)) {
2605
- return links.extendedContainersByFile.get(id)!;
2604
+ let results: Symbol[] | undefined;
2605
+ if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) {
2606
+ return results;
2606
2607
}
2607
- const results: Symbol[] = [];
2608
2608
if (containingFile && containingFile.imports) {
2609
2609
// Try to make an import using an import already in the enclosing file, if possible
2610
2610
for (const importRef of containingFile.imports) {
@@ -2613,11 +2613,11 @@ namespace ts {
2613
2613
if (!resolvedModule) continue;
2614
2614
const ref = getAliasForSymbolInContainer(resolvedModule, symbol);
2615
2615
if (!ref) continue;
2616
- results.push( resolvedModule);
2616
+ results = append(results, resolvedModule);
2617
2617
}
2618
2618
if (length(results)) {
2619
- (links.extendedContainersByFile || (links.extendedContainersByFile = createMap())).set(id, results);
2620
- return results;
2619
+ (links.extendedContainersByFile || (links.extendedContainersByFile = createMap())).set(id, results! );
2620
+ return results! ;
2621
2621
}
2622
2622
}
2623
2623
if (links.extendedContainers) {
@@ -2630,9 +2630,9 @@ namespace ts {
2630
2630
const sym = getSymbolOfNode(file);
2631
2631
const ref = getAliasForSymbolInContainer(sym, symbol);
2632
2632
if (!ref) continue;
2633
- results.push( sym);
2633
+ results = append(results, sym);
2634
2634
}
2635
- return links.extendedContainers = results;
2635
+ return links.extendedContainers = results || emptyArray ;
2636
2636
}
2637
2637
2638
2638
/**
@@ -3989,7 +3989,7 @@ namespace ts {
3989
3989
/** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */
3990
3990
function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined {
3991
3991
let accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & NodeBuilderFlags.UseOnlyExternalAliasing));
3992
- let parentSpecifiers: (string | undefined)[] | undefined ;
3992
+ let parentSpecifiers: (string | undefined)[];
3993
3993
if (!accessibleSymbolChain ||
3994
3994
needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
3995
3995
@@ -4029,14 +4029,15 @@ namespace ts {
4029
4029
}
4030
4030
4031
4031
function sortByBestName(a: number, b: number) {
4032
- const specifierA = parentSpecifiers! [a];
4033
- const specifierB = parentSpecifiers! [b];
4032
+ const specifierA = parentSpecifiers[a];
4033
+ const specifierB = parentSpecifiers[b];
4034
4034
if (specifierA && specifierB) {
4035
- if (pathIsRelative(specifierA) === pathIsRelative(specifierB)) {
4035
+ const isBRelative = pathIsRelative(specifierB);
4036
+ if (pathIsRelative(specifierA) === isBRelative) {
4036
4037
// Both relative or both non-relative, sort by number of parts
4037
4038
return moduleSpecifiers.countPathComponents(specifierA) - moduleSpecifiers.countPathComponents(specifierB);
4038
4039
}
4039
- if (pathIsRelative(specifierB) ) {
4040
+ if (isBRelative ) {
4040
4041
// A is non-relative, B is relative: prefer A
4041
4042
return -1;
4042
4043
}
0 commit comments