Skip to content

Commit 5e2c7ff

Browse files
author
Andy
authored
isValidMethodAccess: use getTypeOfPropertyOfType instead of getTypeOfFuncClassEnumModule (microsoft#24488)
1 parent 20e5617 commit 5e2c7ff

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17428,7 +17428,7 @@ namespace ts {
1742817428
&& (!(property.flags & SymbolFlags.Method) || isValidMethodAccess(property, type));
1742917429
}
1743017430
function isValidMethodAccess(method: Symbol, actualThisType: Type): boolean {
17431-
const propType = getTypeOfFuncClassEnumModule(method);
17431+
const propType = getTypeOfPropertyOfType(actualThisType, method.escapedName)!;
1743217432
const signatures = getSignaturesOfType(getNonNullableType(propType), SignatureKind.Call);
1743317433
Debug.assert(signatures.length !== 0);
1743417434
return signatures.some(sig => {

tests/cases/fourslash/completionsMethodWithThisParameter.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//// value: T; // Make the type parameter actually matter
55
//// ms(this: A<string>) {}
66
//// mo(this: A<{}>) {}
7+
//// mt(this: A<T>) {}
78
//// mp<P>(this: A<P>) {}
89
//// mps<P extends string>(this: A<P>) {}
910
////}
@@ -13,5 +14,5 @@
1314
////s./*s*/;
1415
////n./*n*/;
1516

16-
verify.completionsAt("s", ["value", "ms", "mo", "mp", "mps"]);
17-
verify.completionsAt("n", ["value", "mo", "mp"]);
17+
verify.completionsAt("s", ["value", "ms", "mo", "mt", "mp", "mps"]);
18+
verify.completionsAt("n", ["value", "mo", "mt", "mp"]);

0 commit comments

Comments
 (0)