From 2fb6eabc2e1ced76709d6545c0a1c3508d3321cf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 8 Oct 2015 08:11:33 -0700 Subject: [PATCH] Fix this.member completion+quickinfo of overloads 1. Completion after `this.` was empty. 2. Quick info of methods with overloads always chose the first overload, regardless of whether an argument whose type matched a different overload. Both have the same cause: the type parameter introduced by polymorphic `this` is not usable, whereas the original is. In both cases, the usage is simple -- it doesn't take advantage of the capabilities of polymorphic `this`. --- src/compiler/checker.ts | 5 +++++ src/services/services.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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; }