Skip to content

Commit 57220f2

Browse files
committed
Best key yet
1 parent 097a784 commit 57220f2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/services/exportInfoMap.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ namespace ts {
186186
function key(importedName: string, symbol: Symbol, moduleName: string, checker: TypeChecker) {
187187
const unquoted = stripQuotes(moduleName);
188188
const moduleKey = isExternalModuleNameRelative(unquoted) ? "/" : unquoted;
189-
const targetKey = symbol.flags & SymbolFlags.Alias ? createSymbolKey(skipAlias(symbol, checker)) : moduleName;
190-
return `${importedName}|${targetKey}|${moduleKey}`;
189+
return `${importedName}|${createSymbolKey(skipAlias(symbol, checker), unquoted)}|${moduleKey}`;
191190
}
192191

193192
function parseKey(key: string) {
@@ -197,15 +196,20 @@ namespace ts {
197196
return { symbolName, ambientModuleName };
198197
}
199198

200-
function createSymbolKey(symbol: Symbol) {
199+
function createSymbolKey(symbol: Symbol, sourceModuleName: string) {
201200
let key = symbol.name;
201+
let seenModule = false;
202202
while (symbol.parent) {
203+
seenModule = isExternalModuleSymbol(symbol.parent);
203204
key += `,${symbol.parent.name}`;
204205
symbol = symbol.parent;
205206
}
206-
const decl = symbol.declarations?.[0];
207-
const fileName = decl && getSourceFileOfNode(decl).fileName;
208-
return `${key},${fileName}`;
207+
if (!seenModule) {
208+
const decl = symbol.declarations?.[0];
209+
const fileName = decl && getSourceFileOfNode(decl).fileName;
210+
key += fileName || sourceModuleName;
211+
}
212+
return key;
209213
}
210214

211215
function fileIsGlobalOnly(file: SourceFile) {

0 commit comments

Comments
 (0)