@@ -3032,16 +3032,9 @@ namespace ts.Completions {
3032
3032
? checker . getUnionType ( [ contextualType , completionsType ! ] )
3033
3033
: contextualType ;
3034
3034
3035
- const properties = type . isUnion ( )
3036
- ? checker . getAllPossiblePropertiesOfTypes ( type . types . filter ( memberType =>
3037
- // 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.
3038
- ! ( memberType . flags & TypeFlags . Primitive ||
3039
- checker . isArrayLikeType ( memberType ) ||
3040
- typeHasCallOrConstructSignatures ( memberType , checker ) ||
3041
- checker . isTypeInvalidDueToUnionDiscriminant ( memberType , obj ) ) ) )
3042
- : type . getApparentProperties ( ) ;
3043
-
3044
- return hasCompletionsType ? properties . filter ( hasDeclarationOtherThanSelf ) : properties ;
3035
+ const properties = getApparentProperties ( type , obj , checker ) ;
3036
+ return type . isClass ( ) && containsNonPublicProperties ( properties ) ? [ ] :
3037
+ hasCompletionsType ? filter ( properties , hasDeclarationOtherThanSelf ) : properties ;
3045
3038
3046
3039
// Filter out members whose only declaration is the object literal itself to avoid
3047
3040
// self-fulfilling completions like:
@@ -3053,6 +3046,20 @@ namespace ts.Completions {
3053
3046
}
3054
3047
}
3055
3048
3049
+ function getApparentProperties ( type : Type , node : ObjectLiteralExpression | JsxAttributes , checker : TypeChecker ) {
3050
+ if ( ! type . isUnion ( ) ) return type . getApparentProperties ( ) ;
3051
+ return checker . getAllPossiblePropertiesOfTypes ( filter ( type . types , memberType =>
3052
+ ! ( memberType . flags & TypeFlags . Primitive
3053
+ || checker . isArrayLikeType ( memberType )
3054
+ || checker . isTypeInvalidDueToUnionDiscriminant ( memberType , node )
3055
+ || typeHasCallOrConstructSignatures ( memberType , checker )
3056
+ || memberType . isClass ( ) && containsNonPublicProperties ( memberType . getApparentProperties ( ) ) ) ) ) ;
3057
+ }
3058
+
3059
+ function containsNonPublicProperties ( props : Symbol [ ] ) {
3060
+ return some ( props , p => ! ! ( getDeclarationModifierFlagsFromSymbol ( p ) & ModifierFlags . NonPublicAccessibilityModifier ) ) ;
3061
+ }
3062
+
3056
3063
/**
3057
3064
* Gets all properties on a type, but if that type is a union of several types,
3058
3065
* excludes array-like types or callable/constructable types.
0 commit comments