@@ -18593,8 +18593,6 @@ namespace ts {
18593
18593
inferTypes(context.inferences, thisArgumentType, thisType);
18594
18594
}
18595
18595
18596
- // We perform two passes over the arguments. In the first pass we infer from all arguments, but use
18597
- // wildcards for all context sensitive function expressions.
18598
18596
const effectiveArgCount = getEffectiveArgumentCount(node, args, signature);
18599
18597
const genericRestType = getGenericRestType(signature);
18600
18598
const argCount = genericRestType ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount;
@@ -18621,21 +18619,6 @@ namespace ts {
18621
18619
inferTypes(context.inferences, spreadType, genericRestType);
18622
18620
}
18623
18621
18624
- // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this
18625
- // time treating function expressions normally (which may cause previously inferred type arguments to be fixed
18626
- // as we construct types for contextually typed parameters)
18627
- // Decorators will not have `excludeArgument`, as their arguments cannot be contextually typed.
18628
- // Tagged template expressions will always have `undefined` for `excludeArgument[0]`.
18629
- if (excludeArgument) {
18630
- for (let i = 0; i < argCount; i++) {
18631
- // No need to check for omitted args and template expressions, their exclusion value is always undefined
18632
- if (excludeArgument[i] === false) {
18633
- const arg = args[i];
18634
- const paramType = getTypeAtPosition(signature, i);
18635
- inferTypes(context.inferences, checkExpressionWithContextualType(arg, paramType, context), paramType);
18636
- }
18637
- }
18638
- }
18639
18622
return getInferredTypes(context);
18640
18623
}
18641
18624
@@ -19205,23 +19188,20 @@ namespace ts {
19205
19188
19206
19189
const args = getEffectiveCallArguments(node);
19207
19190
19208
- // The following applies to any value of 'excludeArgument[i]':
19209
- // - true: the argument at 'i' is susceptible to a one-time permanent contextual typing.
19210
- // - undefined: the argument at 'i' is *not* susceptible to permanent contextual typing.
19211
- // - false: the argument at 'i' *was* and *has been* permanently contextually typed.
19191
+ // The excludeArgument array contains true for each context sensitive argument (an argument
19192
+ // is context sensitive it is susceptible to a one-time permanent contextual typing).
19212
19193
//
19213
19194
// The idea is that we will perform type argument inference & assignability checking once
19214
- // without using the susceptible parameters that are functions, and once more for each of those
19195
+ // without using the susceptible parameters that are functions, and once more for those
19215
19196
// parameters, contextually typing each as we go along.
19216
19197
//
19217
- // For a tagged template, then the first argument be 'undefined' if necessary
19218
- // because it represents a TemplateStringsArray.
19198
+ // For a tagged template, then the first argument be 'undefined' if necessary because it
19199
+ // represents a TemplateStringsArray.
19219
19200
//
19220
19201
// For a decorator, no arguments are susceptible to contextual typing due to the fact
19221
19202
// decorators are applied to a declaration by the emitter, and not to an expression.
19222
19203
const isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
19223
19204
let excludeArgument: boolean[] | undefined;
19224
- let excludeCount = 0;
19225
19205
if (!isDecorator && !isSingleNonGenericCandidate) {
19226
19206
// We do not need to call `getEffectiveArgumentCount` here as it only
19227
19207
// applies when calculating the number of arguments for a decorator.
@@ -19231,7 +19211,6 @@ namespace ts {
19231
19211
excludeArgument = new Array(args!.length);
19232
19212
}
19233
19213
excludeArgument[i] = true;
19234
- excludeCount++;
19235
19214
}
19236
19215
}
19237
19216
}
@@ -19379,17 +19358,13 @@ namespace ts {
19379
19358
candidateForArgumentError = candidate;
19380
19359
break;
19381
19360
}
19382
- if (excludeCount === 0) {
19361
+ // If no arguments were excluded, we're done
19362
+ if (!excludeArgument) {
19383
19363
candidates[candidateIndex] = candidate;
19384
19364
return candidate;
19385
19365
}
19386
- excludeCount--;
19387
- if (excludeCount > 0) {
19388
- excludeArgument![excludeArgument!.indexOf(/*value*/ true)] = false;
19389
- }
19390
- else {
19391
- excludeArgument = undefined;
19392
- }
19366
+ // Otherwise, stop excluding arguments and perform a second pass
19367
+ excludeArgument = undefined;
19393
19368
}
19394
19369
}
19395
19370
0 commit comments