Skip to content

Commit cdcfbc2

Browse files
committed
Make sure that global module re-exports are short-cutted to be added to completions
1 parent c40ddb1 commit cdcfbc2

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/services/completions.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1343,12 +1343,9 @@ namespace ts.Completions {
13431343
}
13441344

13451345
const symbolId = getSymbolId(symbol);
1346-
const existingSymbol = findLast(symbols, symbol => symbol.id === symbolId);
1347-
if (!existingSymbol) {
1348-
symbols.push(symbol);
1349-
symbolToOriginInfoMap[symbolId] = origin;
1350-
symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions;
1351-
}
1346+
symbols.push(symbol);
1347+
symbolToOriginInfoMap[symbolId] = origin;
1348+
symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions;
13521349
});
13531350
}
13541351
filterGlobalCompletion(symbols);
@@ -1468,7 +1465,7 @@ namespace ts.Completions {
14681465
}
14691466

14701467
/**
1471-
* Gathers symbols that can be imported from other files, deduplicating along the way. Symbols can be duplicates
1468+
* Gathers symbols that can be imported from other files, de-duplicating along the way. Symbols can be "duplicates"
14721469
* if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but
14731470
* it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out,
14741471
* if and only if the the first can be imported (it may be excluded due to package.json filtering in
@@ -1552,7 +1549,8 @@ namespace ts.Completions {
15521549
// Don't add another completion for `export =` of a symbol that's already global.
15531550
// So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`.
15541551
if (resolvedModuleSymbol !== moduleSymbol &&
1555-
every(resolvedModuleSymbol.declarations, d => !!d.getSourceFile().externalModuleIndicator)) {
1552+
every(resolvedModuleSymbol.declarations, d => !!d.getSourceFile().externalModuleIndicator && !findAncestor(d, ts.isGlobalScopeAugmentation))
1553+
) {
15561554
pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true);
15571555
}
15581556

0 commit comments

Comments
 (0)