Skip to content

Commit 2fb6eab

Browse files
committed
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`.
1 parent 78ad0f4 commit 2fb6eab

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/compiler/checker.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7977,6 +7977,11 @@ namespace ts {
79777977
return true;
79787978
}
79797979
// An instance property must be accessed through an instance of the enclosing class
7980+
if (type.flags & TypeFlags.ThisType) {
7981+
// get the original type -- represented as the type constraint of the this type
7982+
type = getConstraintOfTypeParameter(<TypeParameter>type);
7983+
}
7984+
79807985
// TODO: why is the first part of this check here?
79817986
if (!(getTargetType(type).flags & (TypeFlags.Class | TypeFlags.Interface) && hasBaseType(<InterfaceType>type, enclosingClass))) {
79827987
error(node, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));

‎src/services/services.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4105,7 +4105,7 @@ namespace ts {
41054105
let useConstructSignatures = callExpression.kind === SyntaxKind.NewExpression || callExpression.expression.kind === SyntaxKind.SuperKeyword;
41064106
let allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures();
41074107

4108-
if (!contains(allSignatures, signature.target || signature)) {
4108+
if (!contains(allSignatures, signature.target) && !contains(allSignatures, signature)) {
41094109
// Get the first signature if there
41104110
signature = allSignatures.length ? allSignatures[0] : undefined;
41114111
}

0 commit comments

Comments
 (0)