Infer implied arity before inferring from 'this' argument (#39328)

* Infer implied arity before inferring from 'this' argument

* Add regression test
This commit is contained in:
Anders Hejlsberg
2020-06-29 17:38:41 -07:00
committed by GitHub
parent 9458f8acab
commit 784396ce95
6 changed files with 110 additions and 7 deletions

View File

@@ -25773,13 +25773,6 @@ namespace ts {
}
}
const thisType = getThisTypeOfSignature(signature);
if (thisType) {
const thisArgumentNode = getThisArgumentOfCall(node);
const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
inferTypes(context.inferences, thisArgumentType, thisType);
}
const restType = getNonArrayRestType(signature);
const argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
if (restType && restType.flags & TypeFlags.TypeParameter) {
@@ -25788,6 +25781,14 @@ namespace ts {
info.impliedArity = findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined;
}
}
const thisType = getThisTypeOfSignature(signature);
if (thisType) {
const thisArgumentNode = getThisArgumentOfCall(node);
const thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType;
inferTypes(context.inferences, thisArgumentType, thisType);
}
for (let i = 0; i < argCount; i++) {
const arg = args[i];
if (arg.kind !== SyntaxKind.OmittedExpression) {