@@ -3050,16 +3050,9 @@ namespace ts.Completions {
3050
3050
? checker . getUnionType ( [ contextualType , completionsType ! ] )
3051
3051
: contextualType ;
3052
3052
3053
- const properties = type . isUnion ( )
3054
- ? checker . getAllPossiblePropertiesOfTypes ( type . types . filter ( memberType =>
3055
- // If we're providing completions for an object literal, skip primitive, array-like, or callable types since those shouldn't be implemented by object literals.
3056
- ! ( memberType . flags & TypeFlags . Primitive ||
3057
- checker . isArrayLikeType ( memberType ) ||
3058
- typeHasCallOrConstructSignatures ( memberType , checker ) ||
3059
- checker . isTypeInvalidDueToUnionDiscriminant ( memberType , obj ) ) ) )
3060
- : type . getApparentProperties ( ) ;
3061
-
3062
- return hasCompletionsType ? properties . filter ( hasDeclarationOtherThanSelf ) : properties ;
3053
+ const properties = getApparentProperties ( type , obj , checker ) ;
3054
+ return type . isClass ( ) && containsNonPublicProperties ( properties ) ? [ ] :
3055
+ hasCompletionsType ? filter ( properties , hasDeclarationOtherThanSelf ) : properties ;
3063
3056
3064
3057
// Filter out members whose only declaration is the object literal itself to avoid
3065
3058
// self-fulfilling completions like:
@@ -3071,6 +3064,20 @@ namespace ts.Completions {
3071
3064
}
3072
3065
}
3073
3066
3067
+ function getApparentProperties ( type : Type , node : ObjectLiteralExpression | JsxAttributes , checker : TypeChecker ) {
3068
+ if ( ! type . isUnion ( ) ) return type . getApparentProperties ( ) ;
3069
+ return checker . getAllPossiblePropertiesOfTypes ( filter ( type . types , memberType =>
3070
+ ! ( memberType . flags & TypeFlags . Primitive
3071
+ || checker . isArrayLikeType ( memberType )
3072
+ || checker . isTypeInvalidDueToUnionDiscriminant ( memberType , node )
3073
+ || typeHasCallOrConstructSignatures ( memberType , checker )
3074
+ || memberType . isClass ( ) && containsNonPublicProperties ( memberType . getApparentProperties ( ) ) ) ) ) ;
3075
+ }
3076
+
3077
+ function containsNonPublicProperties ( props : Symbol [ ] ) {
3078
+ return some ( props , p => ! ! ( getDeclarationModifierFlagsFromSymbol ( p ) & ModifierFlags . NonPublicAccessibilityModifier ) ) ;
3079
+ }
3080
+
3074
3081
/**
3075
3082
* Gets all properties on a type, but if that type is a union of several types,
3076
3083
* excludes array-like types or callable/constructable types.
0 commit comments