@@ -10514,9 +10514,9 @@ namespace ts {
10514
10514
}
10515
10515
10516
10516
const sourceCount = getParameterCount(source);
10517
- const sourceRestTypeParameter = getRestTypeParameter (source);
10518
- const targetRestTypeParameter = sourceRestTypeParameter ? getRestTypeParameter (target) : undefined;
10519
- if (sourceRestTypeParameter && !(targetRestTypeParameter && sourceCount === targetCount)) {
10517
+ const sourceGenericRestType = getGenericRestType (source);
10518
+ const targetGenericRestType = sourceGenericRestType ? getGenericRestType (target) : undefined;
10519
+ if (sourceGenericRestType && !(targetGenericRestType && sourceCount === targetCount)) {
10520
10520
return Ternary.False;
10521
10521
}
10522
10522
@@ -10545,8 +10545,8 @@ namespace ts {
10545
10545
const paramCount = Math.max(sourceCount, targetCount);
10546
10546
const lastIndex = paramCount - 1;
10547
10547
for (let i = 0; i < paramCount; i++) {
10548
- const sourceType = i === lastIndex && sourceRestTypeParameter || getTypeAtPosition(source, i);
10549
- const targetType = i === lastIndex && targetRestTypeParameter || getTypeAtPosition(target, i);
10548
+ const sourceType = i === lastIndex && sourceGenericRestType || getTypeAtPosition(source, i);
10549
+ const targetType = i === lastIndex && targetGenericRestType || getTypeAtPosition(target, i);
10550
10550
// In order to ensure that any generic type Foo<T> is at least co-variant with respect to T no matter
10551
10551
// how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions,
10552
10552
// they naturally relate only contra-variantly). However, if the source and target parameters both have
@@ -12821,13 +12821,13 @@ namespace ts {
12821
12821
sourceHasRest ? targetCount :
12822
12822
targetHasRest ? sourceCount :
12823
12823
Math.min(sourceCount, targetCount);
12824
- const targetRestTypeVariable = getRestTypeParameter (target);
12825
- const paramCount = targetRestTypeVariable ? Math.min(targetCount - 1, maxCount) : maxCount;
12824
+ const targetGenericRestType = getGenericRestType (target);
12825
+ const paramCount = targetGenericRestType ? Math.min(targetCount - 1, maxCount) : maxCount;
12826
12826
for (let i = 0; i < paramCount; i++) {
12827
12827
callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
12828
12828
}
12829
- if (targetRestTypeVariable ) {
12830
- callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable );
12829
+ if (targetGenericRestType ) {
12830
+ callback(getRestTypeAtPosition(source, paramCount), targetGenericRestType );
12831
12831
}
12832
12832
}
12833
12833
@@ -18398,8 +18398,8 @@ namespace ts {
18398
18398
// We perform two passes over the arguments. In the first pass we infer from all arguments, but use
18399
18399
// wildcards for all context sensitive function expressions.
18400
18400
const effectiveArgCount = getEffectiveArgumentCount(node, args, signature);
18401
- const restTypeParameter = getRestTypeParameter (signature);
18402
- const argCount = restTypeParameter ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount;
18401
+ const genericRestType = getGenericRestType (signature);
18402
+ const argCount = genericRestType ? Math.min(getParameterCount(signature) - 1, effectiveArgCount) : effectiveArgCount;
18403
18403
for (let i = 0; i < argCount; i++) {
18404
18404
const arg = getEffectiveArgument(node, args, i);
18405
18405
// If the effective argument is 'undefined', then it is an argument that is present but is synthetic.
@@ -18418,9 +18418,9 @@ namespace ts {
18418
18418
}
18419
18419
}
18420
18420
18421
- if (restTypeParameter ) {
18422
- const spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, restTypeParameter , context);
18423
- inferTypes(context.inferences, spreadType, restTypeParameter );
18421
+ if (genericRestType ) {
18422
+ const spreadType = getSpreadArgumentType(node, args, argCount, effectiveArgCount, genericRestType , context);
18423
+ inferTypes(context.inferences, spreadType, genericRestType );
18424
18424
}
18425
18425
18426
18426
// In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this
@@ -19170,9 +19170,9 @@ namespace ts {
19170
19170
}
19171
19171
const isJavascript = isInJavaScriptFile(candidate.declaration);
19172
19172
candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript);
19173
- // If the original signature has a rest type parameter , instantiation may produce a
19173
+ // If the original signature has a generic rest type, instantiation may produce a
19174
19174
// signature with different arity and we need to perform another arity check.
19175
- if (getRestTypeParameter (originalCandidate) && !hasCorrectArity(node, args!, candidate, signatureHelpTrailingComma)) {
19175
+ if (getGenericRestType (originalCandidate) && !hasCorrectArity(node, args!, candidate, signatureHelpTrailingComma)) {
19176
19176
candidateForArgumentArityError = candidate;
19177
19177
break;
19178
19178
}
@@ -20104,9 +20104,9 @@ namespace ts {
20104
20104
const paramCount = getParameterCount(source);
20105
20105
const hasRest = hasEffectiveRestParameter(source);
20106
20106
if (hasRest && pos === paramCount - 1) {
20107
- const restTypeVariable = getRestTypeParameter (source);
20108
- if (restTypeVariable ) {
20109
- return restTypeVariable ;
20107
+ const genericRestType = getGenericRestType (source);
20108
+ if (genericRestType ) {
20109
+ return genericRestType ;
20110
20110
}
20111
20111
}
20112
20112
const start = hasRest ? Math.min(pos, paramCount - 1) : pos;
@@ -20156,11 +20156,11 @@ namespace ts {
20156
20156
return signature.minArgumentCount;
20157
20157
}
20158
20158
20159
- function getRestTypeParameter (signature: Signature) {
20159
+ function getGenericRestType (signature: Signature) {
20160
20160
if (signature.hasRestParameter) {
20161
20161
const restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
20162
- if (restType.flags & TypeFlags.TypeParameter ) {
20163
- return <TypeParameter> restType;
20162
+ if (restType.flags & TypeFlags.Instantiable ) {
20163
+ return restType;
20164
20164
}
20165
20165
}
20166
20166
return undefined;
0 commit comments