@@ -10497,9 +10497,9 @@ namespace ts {
10497
10497
}
10498
10498
10499
10499
const sourceCount = getParameterCount(source);
10500
- const sourceRestTypeParameter = getRestTypeParameter (source);
10501
- const targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter (target) : undefined;
10502
- if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) {
10500
+ const sourceGenericRestType = getGenericRestType (source);
10501
+ const targetGenericRestType = sourceGenericRestType ? getGenericRestType (target) : undefined;
10502
+ if (sourceGenericRestType && !(targetGenericRestType && sourceCount === targetCount)) {
10503
10503
return Ternary.False;
10504
10504
}
10505
10505
@@ -10528,8 +10528,8 @@ namespace ts {
10528
10528
const paramCount = Math.max(sourceCount, targetCount);
10529
10529
const lastIndex = paramCount - 1;
10530
10530
for (let i = 0; i < paramCount; i++) {
10531
- const sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i);
10532
- const targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i);
10531
+ const sourceType = i === lastIndex && sourceGenericRestType || getTypeAtPosition(source, i);
10532
+ const targetType = i === lastIndex && targetGenericRestType || getTypeAtPosition(target, i);
10533
10533
// In order to ensure that any generic type Foo<T> is at least co-variant with respect to T no matter
10534
10534
// how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions,
10535
10535
// they naturally relate only contra-variantly). However, if the source and target parameters both have
@@ -12804,13 +12804,13 @@ namespace ts {
12804
12804
sourceHasRest ? targetCount :
12805
12805
targetHasRest ? sourceCount :
12806
12806
Math.min(sourceCount, targetCount);
12807
- const targetRestTypeVariable = getRestTypeParameter (target);
12808
- const paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount;
12807
+ const targetGenericRestType = getGenericRestType (target);
12808
+ const paramCount = targetGenericRestType ? Math.min(targetCount - 1, maxCount) : maxCount;
12809
12809
for (let i = 0; i < paramCount; i++) {
12810
12810
callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
12811
12811
}
12812
- if (targetRestTypeVariable ) {
12813
- callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable );
12812
+ if (targetGenericRestType ) {
12813
+ callback(getRestTypeAtPosition(source, paramCount), targetGenericRestType );
12814
12814
}
12815
12815
}
12816
12816
@@ -18380,8 +18380,8 @@ namespace ts {
18380
18380
// We perform two passes over the arguments. In the first pass we infer from all arguments, but use
18381
18381
// wildcards for all context sensitive function expressions.
18382
18382
const effectiveArgCount = getEffectiveArgumentCount(node, args, signature);
18383
- const restTypeParameter = getRestTypeParameter (signature);
18384
- const argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount;
18383
+ const genericRestType = getGenericRestType (signature);
18384
+ const argCount = genericRestType ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount;
18385
18385
for (let i = 0; i < argCount; i++) {
18386
18386
const arg = getEffectiveArgument(node, args, i);
18387
18387
// If the effective argument is 'undefined', then it is an argument that is present but is synthetic.
@@ -18400,9 +18400,9 @@ namespace ts {
18400
18400
}
18401
18401
}
18402
18402
18403
- if (restTypeParameter ) {
18404
- const spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter , context);
18405
- inferTypes(context.inferences, spreadType, restTypeParameter );
18403
+ if (genericRestType ) {
18404
+ const spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, genericRestType , context);
18405
+ inferTypes(context.inferences, spreadType, genericRestType );
18406
18406
}
18407
18407
18408
18408
// In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this
@@ -19152,9 +19152,9 @@ namespace ts {
19152
19152
}
19153
19153
const isJavascript = isInJavaScriptFile(candidate.declaration);
19154
19154
candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript);
19155
- // If the original signature has a rest type parameter , instantiation may produce a
19155
+ // If the original signature has a generic rest type, instantiation may produce a
19156
19156
// signature with different arity and we need to perform another arity check.
19157
- if (getRestTypeParameter (originalCandidate) && !hasCorrectArity(node, args!, candidate, signatureHelpTrailingComma)) {
19157
+ if (getGenericRestType (originalCandidate) && !hasCorrectArity(node, args!, candidate, signatureHelpTrailingComma)) {
19158
19158
candidateForArgumentArityError = candidate;
19159
19159
break;
19160
19160
}
@@ -20084,9 +20084,9 @@ namespace ts {
20084
20084
const paramCount = getParameterCount(source);
20085
20085
const hasRest = hasEffectiveRestParameter(source);
20086
20086
if (hasRest && pos === paramCount - 1) {
20087
- const restTypeVariable = getRestTypeParameter (source);
20088
- if (restTypeVariable ) {
20089
- return restTypeVariable ;
20087
+ const genericRestType = getGenericRestType (source);
20088
+ if (genericRestType ) {
20089
+ return genericRestType ;
20090
20090
}
20091
20091
}
20092
20092
const start = hasRest ? Math.min(pos, paramCount - 1) : pos;
@@ -20136,11 +20136,11 @@ namespace ts {
20136
20136
return signature.minArgumentCount;
20137
20137
}
20138
20138
20139
- function getRestTypeParameter (signature: Signature) {
20139
+ function getGenericRestType (signature: Signature) {
20140
20140
if (signature.hasRestParameter) {
20141
20141
const restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
20142
- if (restType.flags & TypeFlags.TypeParameter ) {
20143
- return <TypeParameter> restType;
20142
+ if (restType.flags & TypeFlags.Instantiable ) {
20143
+ return restType;
20144
20144
}
20145
20145
}
20146
20146
return undefined;
0 commit comments