Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 765114f

Browse filesBrowse files
author
Andy Hanson
committed
Refactor to move code into checker
1 parent 890676a commit 765114f
Copy full SHA for 765114f

3 files changed

+18-14Lines changed: 18 additions & 14 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/checker.ts‎

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace ts {
108108
getAliasedSymbol: resolveAlias,
109109
getEmitResolver,
110110
getExportsOfModule: getExportsOfModuleAsArray,
111-
resolveExternalModuleSymbol,
111+
getExportsAndPropertiesOfModule,
112112
getAmbientModules,
113113
getJsxElementAttributesType,
114114
getJsxIntrinsicTagNames,
@@ -1528,6 +1528,15 @@ namespace ts {
15281528
return symbolsToArray(getExportsOfModule(moduleSymbol));
15291529
}
15301530

1531+
function getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[] {
1532+
const exports = getExportsOfModuleAsArray(moduleSymbol);
1533+
const exportEquals = resolveExternalModuleSymbol(moduleSymbol);
1534+
if (exportEquals !== moduleSymbol) {
1535+
addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals)));
1536+
}
1537+
return exports;
1538+
}
1539+
15311540
function tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined {
15321541
const symbolTable = getExportsOfModule(moduleSymbol);
15331542
if (symbolTable) {
Collapse file

‎src/compiler/types.ts‎

Copy file name to clipboardExpand all lines: src/compiler/types.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2370,7 +2370,8 @@ namespace ts {
23702370
isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean;
23712371
getAliasedSymbol(symbol: Symbol): Symbol;
23722372
getExportsOfModule(moduleSymbol: Symbol): Symbol[];
2373-
/* @internal */ resolveExternalModuleSymbol(moduleSymbol: Symbol): Symbol;
2373+
/** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */
2374+
/* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[];
23742375

23752376
getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type;
23762377
getJsxIntrinsicTagNames(): Symbol[];
Collapse file

‎src/services/completions.ts‎

Copy file name to clipboardExpand all lines: src/services/completions.ts
+6-12Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,20 +1318,14 @@ namespace ts.Completions {
13181318
isMemberCompletion = true;
13191319
isNewIdentifierLocation = false;
13201320

1321-
let exports: Symbol[];
1322-
const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importOrExportDeclaration.moduleSpecifier);
1323-
if (moduleSpecifierSymbol) {
1324-
exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol);
1325-
const exportEquals = typeChecker.resolveExternalModuleSymbol(moduleSpecifierSymbol);
1326-
if (exportEquals !== moduleSpecifierSymbol) {
1327-
// Location doesn't matter so long as it's not an identifier.
1328-
const exportEqualsType = typeChecker.getTypeOfSymbolAtLocation(exportEquals, moduleSpecifier);
1329-
exports = ts.concatenate(exports, typeChecker.getPropertiesOfType(exportEqualsType));
1330-
}
1321+
const moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier);
1322+
if (!moduleSpecifierSymbol) {
1323+
symbols = emptyArray;
1324+
return true;
13311325
}
13321326

1333-
symbols = exports ? filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements) : emptyArray;
1334-
1327+
const exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol);
1328+
symbols = filterNamedImportOrExportCompletionItems(exports, namedImportsOrExports.elements);
13351329
return true;
13361330
}
13371331

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.