diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fe203ac52c9..32fc57cee3a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7977,6 +7977,11 @@ namespace ts { return true; } // An instance property must be accessed through an instance of the enclosing class + if (type.flags & TypeFlags.ThisType) { + // get the original type -- represented as the type constraint of the this type + type = getConstraintOfTypeParameter(type); + } + // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (TypeFlags.Class | TypeFlags.Interface) && hasBaseType(type, enclosingClass))) { error(node, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); diff --git a/src/services/services.ts b/src/services/services.ts index 99c6e4d6032..5a8241a5c45 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4105,7 +4105,7 @@ namespace ts { let useConstructSignatures = callExpression.kind === SyntaxKind.NewExpression || callExpression.expression.kind === SyntaxKind.SuperKeyword; let allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); - if (!contains(allSignatures, signature.target || signature)) { + if (!contains(allSignatures, signature.target) && !contains(allSignatures, signature)) { // Get the first signature if there signature = allSignatures.length ? allSignatures[0] : undefined; }