From fd3b4ca9cd8a24a1efcfc1f9bc0c4c168942433a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 24 Mar 2015 18:45:22 -0700 Subject: [PATCH] Fixed transitive export completion list issue. --- src/compiler/checker.ts | 8 ++++++-- src/compiler/types.ts | 5 +++-- src/services/services.ts | 9 ++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cc614a34692..73bf603c682 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -74,7 +74,10 @@ module ts { isImplementationOfOverload, getAliasedSymbol: resolveAlias, getEmitResolver, - getExportsOfExternalModule, + getExportsOfImportDeclaration, + getExportsOfModule(moduleSymbol: Symbol): Symbol[] { + return mapToArray(getExportsOfModule(moduleSymbol)); + } }; let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); @@ -794,6 +797,7 @@ module ts { } function getExportsOfSymbol(symbol: Symbol): SymbolTable { + // TODO (drosen): Why do we not use getExportsOfModule for exteral modules as weel? return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports; } @@ -2921,7 +2925,7 @@ module ts { return result; } - function getExportsOfExternalModule(node: ImportDeclaration): Symbol[]{ + function getExportsOfImportDeclaration(node: ImportDeclaration): Symbol[] { if (!node.moduleSpecifier) { return emptyArray; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e615a9d0bbd..d6edc5300d4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -902,7 +902,7 @@ module ts { // import "mod" => importClause = undefined, moduleSpecifier = "mod" // In rest of the cases, module specifier is string literal corresponding to module // ImportClause information is shown at its declaration below. - export interface ImportDeclaration extends Statement, ModuleElement { + export interface ImportDeclaration extends ModuleElement { importClause?: ImportClause; moduleSpecifier: Expression; } @@ -1115,7 +1115,8 @@ module ts { getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; - getExportsOfExternalModule(node: ImportDeclaration): Symbol[]; + getExportsOfImportDeclaration(node: ImportDeclaration): Symbol[]; + getExportsOfModule(moduleSymbol: Symbol): Symbol[]; // Should not be called directly. Should only be accessed through the Program instance. /* @internal */ getDiagnostics(sourceFile?: SourceFile): Diagnostic[]; diff --git a/src/services/services.ts b/src/services/services.ts index 58fba22a71f..980c79c231f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2533,8 +2533,10 @@ module ts { if (symbol && symbol.flags & SymbolFlags.HasExports) { // Extract module or enum members - forEachValue(symbol.exports, symbol => { - if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { + let exportedMembers = typeInfoResolver.getExportsOfModule(symbol); + forEach(exportedMembers, symbol => { + if (!(symbol.flags & SymbolFlags.ExportStar) + && typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { symbols.push(symbol); } }); @@ -2577,7 +2579,8 @@ module ts { if (showCompletionsInImportsClause(previousToken)) { let importDeclaration = getAncestor(previousToken, SyntaxKind.ImportDeclaration); Debug.assert(importDeclaration !== undefined); - let exports = typeInfoResolver.getExportsOfExternalModule(importDeclaration); + + let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); symbols = filterModuleExports(exports, importDeclaration); } }