@@ -2157,7 +2157,7 @@ namespace ts.Completions {
2157
2157
const hasStringIndexType = ( completionsType || instantiatedType ) . getStringIndexType ( ) ;
2158
2158
const hasNumberIndextype = ( completionsType || instantiatedType ) . getNumberIndexType ( ) ;
2159
2159
isNewIdentifierLocation = ! ! hasStringIndexType || ! ! hasNumberIndextype ;
2160
- typeMembers = getPropertiesForObjectExpression ( instantiatedType , completionsType , objectLikeContainer , typeChecker ) ;
2160
+ typeMembers = getPropertiesForObjectExpression ( instantiatedType , completionsType , objectLikeContainer , typeChecker ) || emptyArray ;
2161
2161
existingMembers = objectLikeContainer . properties ;
2162
2162
2163
2163
if ( typeMembers . length === 0 ) {
@@ -3033,15 +3033,11 @@ namespace ts.Completions {
3033
3033
: contextualType ;
3034
3034
3035
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 ) ) ) )
3036
+ ? checker . getAllPossiblePropertiesOfTypes ( filter ( type . types , memberType => isApparentType ( memberType , obj , checker ) ) )
3042
3037
: type . getApparentProperties ( ) ;
3043
3038
3044
- return hasCompletionsType ? properties . filter ( hasDeclarationOtherThanSelf ) : properties ;
3039
+ return type . isClass ( ) && containsHiddenProps ( properties ) ? [ ] :
3040
+ hasCompletionsType ? filter ( properties , hasDeclarationOtherThanSelf ) : properties ;
3045
3041
3046
3042
// Filter out members whose only declaration is the object literal itself to avoid
3047
3043
// self-fulfilling completions like:
@@ -3053,6 +3049,18 @@ namespace ts.Completions {
3053
3049
}
3054
3050
}
3055
3051
3052
+ function isApparentType ( type : Type , node : ObjectLiteralExpression | JsxAttributes , checker : TypeChecker ) {
3053
+ return ! ( type . flags & TypeFlags . Primitive
3054
+ || checker . isArrayLikeType ( type )
3055
+ || checker . isTypeInvalidDueToUnionDiscriminant ( type , node )
3056
+ || typeHasCallOrConstructSignatures ( type , checker )
3057
+ || type . isClass ( ) && containsHiddenProps ( type . getApparentProperties ( ) ) ) ;
3058
+ }
3059
+
3060
+ function containsHiddenProps ( props : Symbol [ ] ) {
3061
+ return some ( props , p => ! ! ( getDeclarationModifierFlagsFromSymbol ( p ) & ModifierFlags . NonPublicAccessibilityModifier ) ) ;
3062
+ }
3063
+
3056
3064
/**
3057
3065
* Gets all properties on a type, but if that type is a union of several types,
3058
3066
* excludes array-like types or callable/constructable types.
0 commit comments