fix(37825): exclude private fields from completions in subclasses (#37906)

This commit is contained in:
Alexander T 2020-04-22 19:07:36 +03:00 committed by GitHub
parent 92a63741a2
commit d2016912b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 1 deletions

View file

@ -2427,7 +2427,8 @@ namespace ts.Completions {
return baseSymbols.filter(propertySymbol =>
!existingMemberNames.has(propertySymbol.escapedName) &&
!!propertySymbol.declarations &&
!(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private));
!(getDeclarationModifierFlagsFromSymbol(propertySymbol) & ModifierFlags.Private) &&
!isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration));
}
/**

View file

@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
////class A {
//// #private = 1;
////}
////
////class B extends A {
//// /**/
////}
verify.completions({
marker: "",
exact: completion.classElementKeywords,
isNewIdentifierLocation: true
});

View file

@ -0,0 +1,21 @@
/// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: a.js
////class A {
//// #private = 1;
////}
////
////class B extends A {
//// /**/
////}
verify.completions({
marker: "",
exact: [
{ name: "A", sortText: completion.SortText.JavascriptIdentifiers },
{ name: "B", sortText: completion.SortText.JavascriptIdentifiers },
...completion.classElementInJsKeywords
],
isNewIdentifierLocation: true
});