Skip to content

Commit d201691

Browse files
authored
fix(37825): exclude private fields from completions in subclasses (#37906)
1 parent 92a6374 commit d201691

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

src/services/completions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,8 @@ namespace ts.Completions {
24272427
return baseSymbols.filter(propertySymbol =>
24282428
!existingMemberNames.has(propertySymbol.escapedName) &&
24292429
!!propertySymbol.declarations &&
2430-
!(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private));
2430+
!(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private) &&
2431+
!isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration));
24312432
}
24322433

24332434
/**
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////class A {
4+
//// #private = 1;
5+
////}
6+
////
7+
////class B extends A {
8+
//// /**/
9+
////}
10+
11+
verify.completions({
12+
marker: "",
13+
exact: completion.classElementKeywords,
14+
isNewIdentifierLocation: true
15+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowJs: true
4+
// @Filename: a.js
5+
////class A {
6+
//// #private = 1;
7+
////}
8+
////
9+
////class B extends A {
10+
//// /**/
11+
////}
12+
13+
verify.completions({
14+
marker: "",
15+
exact: [
16+
{ name: "A", sortText: completion.SortText.JavascriptIdentifiers },
17+
{ name: "B", sortText: completion.SortText.JavascriptIdentifiers },
18+
...completion.classElementInJsKeywords
19+
],
20+
isNewIdentifierLocation: true
21+
});

0 commit comments

Comments
 (0)