fix(31126): show completions in nested namespace name (#39663)

This commit is contained in:
Alexander T 2020-09-03 23:32:03 +03:00 committed by GitHub
parent d89635381a
commit db5f519514
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 2 deletions

View file

@ -1162,13 +1162,12 @@ namespace ts.Completions {
|| isPartOfTypeNode(node.parent)
|| isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker);
const isRhsOfImportDeclaration = isInRightSideOfInternalImportEqualsDeclaration(node);
if (isEntityName(node) || isImportType) {
if (isEntityName(node) || isImportType || isPropertyAccessExpression(node)) {
const isNamespaceName = isModuleDeclaration(node.parent);
if (isNamespaceName) isNewIdentifierLocation = true;
let symbol = typeChecker.getSymbolAtLocation(node);
if (symbol) {
symbol = skipAlias(symbol, typeChecker);
if (symbol.flags & (SymbolFlags.Module | SymbolFlags.Enum)) {
// Extract module or enum members
const exportedSymbols = typeChecker.getExportsOfModule(symbol);

View file

@ -0,0 +1,27 @@
/// <reference path='fourslash.ts'/>
////namespace A {
//// export namespace B {
//// export interface C {}
//// }
////}
////
////interface T1 extends A/*1*/
////
////declare const t2: A/*2*/
////
////const t3 = (x: A/*3*/) => {}
////
////interface T4 {
//// c: A/*4*/
////}
for (const marker of test.markers()) {
goTo.marker(marker);
edit.insert(".");
verify.completions({ exact: ["B"] });
edit.insert("B.");
verify.completions({ exact: ["C"] });
edit.insert("C.");
verify.completions({ exact: undefined });
}