From 5e2c7ffce6462b00af8d65f591b1b6ffc5828100 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 30 May 2018 09:12:24 -0700 Subject: [PATCH] isValidMethodAccess: use getTypeOfPropertyOfType instead of getTypeOfFuncClassEnumModule (#24488) --- src/compiler/checker.ts | 2 +- tests/cases/fourslash/completionsMethodWithThisParameter.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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"]);