diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4555f247980..caa9f394477 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17428,7 +17428,7 @@ namespace ts { && (!(property.flags & SymbolFlags.Method) || isValidMethodAccess(property, type)); } function isValidMethodAccess(method: Symbol, actualThisType: Type): boolean { - const propType = getTypeOfFuncClassEnumModule(method); + const propType = getTypeOfPropertyOfType(actualThisType, method.escapedName)!; const signatures = getSignaturesOfType(getNonNullableType(propType), SignatureKind.Call); Debug.assert(signatures.length !== 0); return signatures.some(sig => { diff --git a/tests/cases/fourslash/completionsMethodWithThisParameter.ts b/tests/cases/fourslash/completionsMethodWithThisParameter.ts index 67829bb1d59..eb7c00421dd 100644 --- a/tests/cases/fourslash/completionsMethodWithThisParameter.ts +++ b/tests/cases/fourslash/completionsMethodWithThisParameter.ts @@ -4,6 +4,7 @@ //// value: T; // Make the type parameter actually matter //// ms(this: A) {} //// mo(this: A<{}>) {} +//// mt(this: A) {} //// mp

(this: A

) {} //// mps

(this: A

) {} ////} @@ -13,5 +14,5 @@ ////s./*s*/; ////n./*n*/; -verify.completionsAt("s", ["value", "ms", "mo", "mp", "mps"]); -verify.completionsAt("n", ["value", "mo", "mp"]); +verify.completionsAt("s", ["value", "ms", "mo", "mt", "mp", "mps"]); +verify.completionsAt("n", ["value", "mo", "mt", "mp"]);