Skip to content

Commit 5db12f3

Browse files
committed
Filter private mebemers in class completions
1 parent 44adc06 commit 5db12f3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/services/services.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1815,7 +1815,17 @@ module ts {
18151815
return undefined;
18161816
}
18171817

1818-
var symbols = apparentType.getApparentProperties();
1818+
var containingClass = getAncestor(mappedNode, SyntaxKind.ClassDeclaration);
1819+
1820+
var symbols: Symbol[] = [];
1821+
// Filter private properties
1822+
forEach(apparentType.getApparentProperties(), symbol => {
1823+
var declaration = symbol.declarations && symbol.declarations[0];
1824+
if (declaration && declaration.flags & NodeFlags.Private && containingClass !== declaration.parent)
1825+
return;
1826+
1827+
symbols.push(symbol);
1828+
});
18191829
isMemberCompletion = true;
18201830
getCompletionEntriesFromSymbols(symbols, activeCompletionSession);
18211831
}

tests/cases/fourslash/memberListOfClass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
goTo.marker();
1313
debug.printCompletionListMembers();
1414
verify.memberListCount(2);
15-
verify.memberListContains('pubMeth', '(): void');
15+
verify.memberListContains('pubMeth', '() => void');
1616
verify.memberListContains('pubProp', 'number');

0 commit comments

Comments
 (0)