isValidMethodAccess: use getTypeOfPropertyOfType instead of getTypeOfFuncClassEnumModule (#24488)

This commit is contained in:
Andy 2018-05-30 09:12:24 -07:00 committed by GitHub
parent 20e5617275
commit 5e2c7ffce6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -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 => {

View File

@ -4,6 +4,7 @@
//// value: T; // Make the type parameter actually matter
//// ms(this: A<string>) {}
//// mo(this: A<{}>) {}
//// mt(this: A<T>) {}
//// mp<P>(this: A<P>) {}
//// mps<P extends string>(this: A<P>) {}
////}
@ -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"]);