From c3437d13ae9e65da477aef242266026221356f02 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 11 Jul 2019 15:10:29 -0700 Subject: [PATCH] Inline `symbolHasBeenSeen` --- src/services/completions.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/services/completions.ts b/src/services/completions.ts index 76029917d32..b95f2ac59a3 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1358,9 +1358,10 @@ namespace ts.Completions { // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). if (some(symbol.declarations, d => isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier)) { // Walk the export chain back one module (step 1 or 2 in diagrammed example) - const nearestExportSymbol = Debug.assertDefined(getNearestExportSymbol(symbol)); - if (!symbolHasBeenSeen(nearestExportSymbol)) { - aliasesToReturnIfOriginalsAreMissing.set(getSymbolId(nearestExportSymbol).toString(), { alias: symbol, moduleSymbol, insertAt: symbols.length }); + const nearestExportSymbolId = getSymbolId(Debug.assertDefined(getNearestExportSymbol(symbol))); + const symbolHasBeenSeen = !!symbolToOriginInfoMap[nearestExportSymbolId] || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId.toString()); + if (!symbolHasBeenSeen) { + aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId.toString(), { alias: symbol, moduleSymbol, insertAt: symbols.length }); aliasesToAlreadyIncludedSymbols.set(getSymbolId(symbol).toString(), true); } else { @@ -1393,11 +1394,6 @@ namespace ts.Completions { symbolToOriginInfoMap[getSymbolId(symbol)] = origin; } } - - function symbolHasBeenSeen(symbol: Symbol) { - const symbolId = getSymbolId(symbol); - return !!symbolToOriginInfoMap[symbolId] || aliasesToAlreadyIncludedSymbols.has(symbolId.toString()); - } } function getNearestExportSymbol(fromSymbol: Symbol) {