Skip to content

Commit 70950cb

Browse files
authored
Merge pull request #31377 from microsoft/noThisParameterFiltering
Revert this-parameter filtering in completions
2 parents 4da2c25 + d292346 commit 70950cb

File tree

2 files changed

+2
-39
lines changed

2 files changed

+2
-39
lines changed

src/compiler/checker.ts

+2-19
Original file line numberDiff line numberDiff line change
@@ -20386,25 +20386,8 @@ namespace ts {
2038620386
}
2038720387

2038820388
function isValidPropertyAccessForCompletions(node: PropertyAccessExpression | ImportTypeNode | QualifiedName, type: Type, property: Symbol): boolean {
20389-
return isValidPropertyAccessWithType(node, node.kind === SyntaxKind.PropertyAccessExpression && node.expression.kind === SyntaxKind.SuperKeyword, property.escapedName, type)
20390-
&& (!(property.flags & SymbolFlags.Method) || isValidMethodAccess(property, type));
20391-
}
20392-
function isValidMethodAccess(method: Symbol, actualThisType: Type): boolean {
20393-
const propType = getTypeOfPropertyOfType(actualThisType, method.escapedName)!;
20394-
const signatures = getSignaturesOfType(getNonNullableType(propType), SignatureKind.Call);
20395-
Debug.assert(signatures.length !== 0);
20396-
return signatures.some(sig => {
20397-
const signatureThisType = getThisTypeOfSignature(sig);
20398-
return !signatureThisType || isTypeAssignableTo(actualThisType, getInstantiatedSignatureThisType(sig, signatureThisType, actualThisType));
20399-
});
20400-
}
20401-
function getInstantiatedSignatureThisType(sig: Signature, signatureThisType: Type, actualThisType: Type): Type {
20402-
if (!sig.typeParameters) {
20403-
return signatureThisType;
20404-
}
20405-
const context = createInferenceContext(sig.typeParameters, sig, InferenceFlags.None);
20406-
inferTypes(context.inferences, actualThisType, signatureThisType);
20407-
return instantiateType(signatureThisType, createSignatureTypeMapper(sig, getInferredTypes(context)));
20389+
return isValidPropertyAccessWithType(node, node.kind === SyntaxKind.PropertyAccessExpression && node.expression.kind === SyntaxKind.SuperKeyword, property.escapedName, type);
20390+
// Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context.
2040820391
}
2040920392

2041020393
function isValidPropertyAccessWithType(

tests/cases/fourslash/completionsMethodWithThisParameter.ts

-20
This file was deleted.

0 commit comments

Comments
 (0)