Skip to content

Commit c053413

Browse files
committed
Minor cleanups
1 parent a04077c commit c053413

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/compiler/checker.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2601,10 +2601,10 @@ namespace ts {
26012601
const containingFile = getSourceFileOfNode(enclosingDeclaration);
26022602
const id = "" + getNodeId(containingFile);
26032603
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;
26062607
}
2607-
const results: Symbol[] = [];
26082608
if (containingFile && containingFile.imports) {
26092609
// Try to make an import using an import already in the enclosing file, if possible
26102610
for (const importRef of containingFile.imports) {
@@ -2613,11 +2613,11 @@ namespace ts {
26132613
if (!resolvedModule) continue;
26142614
const ref = getAliasForSymbolInContainer(resolvedModule, symbol);
26152615
if (!ref) continue;
2616-
results.push(resolvedModule);
2616+
results = append(results, resolvedModule);
26172617
}
26182618
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!;
26212621
}
26222622
}
26232623
if (links.extendedContainers) {
@@ -2630,9 +2630,9 @@ namespace ts {
26302630
const sym = getSymbolOfNode(file);
26312631
const ref = getAliasForSymbolInContainer(sym, symbol);
26322632
if (!ref) continue;
2633-
results.push(sym);
2633+
results = append(results, sym);
26342634
}
2635-
return links.extendedContainers = results;
2635+
return links.extendedContainers = results || emptyArray;
26362636
}
26372637

26382638
/**
@@ -3989,7 +3989,7 @@ namespace ts {
39893989
/** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */
39903990
function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined {
39913991
let accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & NodeBuilderFlags.UseOnlyExternalAliasing));
3992-
let parentSpecifiers: (string | undefined)[] | undefined;
3992+
let parentSpecifiers: (string | undefined)[];
39933993
if (!accessibleSymbolChain ||
39943994
needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
39953995

@@ -4029,14 +4029,15 @@ namespace ts {
40294029
}
40304030

40314031
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];
40344034
if (specifierA && specifierB) {
4035-
if (pathIsRelative(specifierA) === pathIsRelative(specifierB)) {
4035+
const isBRelative = pathIsRelative(specifierB);
4036+
if (pathIsRelative(specifierA) === isBRelative) {
40364037
// Both relative or both non-relative, sort by number of parts
40374038
return moduleSpecifiers.countPathComponents(specifierA) - moduleSpecifiers.countPathComponents(specifierB);
40384039
}
4039-
if (pathIsRelative(specifierB)) {
4040+
if (isBRelative) {
40404041
// A is non-relative, B is relative: prefer A
40414042
return -1;
40424043
}

0 commit comments

Comments
 (0)