diff --git a/src/services/services.ts b/src/services/services.ts index 4f3e84661ad..dd22a6bde56 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2614,6 +2614,7 @@ module ts { case SyntaxKind.VarKeyword: case SyntaxKind.GetKeyword: case SyntaxKind.SetKeyword: + case SyntaxKind.ImportKeyword: return true; } @@ -3061,13 +3062,13 @@ module ts { displayParts.push(keywordPart(SyntaxKind.ImportKeyword)); displayParts.push(spacePart()); addFullSymbolName(symbol); - displayParts.push(spacePart()); - displayParts.push(punctuationPart(SyntaxKind.EqualsToken)); - displayParts.push(spacePart()); ts.forEach(symbol.declarations, declaration => { if (declaration.kind === SyntaxKind.ImportDeclaration) { var importDeclaration = declaration; if (importDeclaration.externalModuleName) { + displayParts.push(spacePart()); + displayParts.push(punctuationPart(SyntaxKind.EqualsToken)); + displayParts.push(spacePart()); displayParts.push(keywordPart(SyntaxKind.RequireKeyword)); displayParts.push(punctuationPart(SyntaxKind.OpenParenToken)); displayParts.push(displayPart(getTextOfNode(importDeclaration.externalModuleName), SymbolDisplayPartKind.stringLiteral)); @@ -3075,7 +3076,12 @@ module ts { } else { var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName); - addFullSymbolName(internalAliasSymbol, enclosingDeclaration); + if (internalAliasSymbol) { + displayParts.push(spacePart()); + displayParts.push(punctuationPart(SyntaxKind.EqualsToken)); + displayParts.push(spacePart()); + addFullSymbolName(internalAliasSymbol, enclosingDeclaration); + } } return true; } diff --git a/tests/cases/fourslash/completionEntryForImportName.ts b/tests/cases/fourslash/completionEntryForImportName.ts new file mode 100644 index 00000000000..08e46c40720 --- /dev/null +++ b/tests/cases/fourslash/completionEntryForImportName.ts @@ -0,0 +1,14 @@ +/// + +////import /*1*/q = /*2*/ + +verifyIncompleteImport(); +goTo.marker('2'); +edit.insert("a."); +verifyIncompleteImport(); + +function verifyIncompleteImport() { + goTo.marker('1'); + verify.completionListIsEmpty(); + verify.quickInfoIs("import q"); +} \ No newline at end of file