@@ -10514,9 +10514,9 @@ namespace ts {
1051410514 }
1051510515
1051610516 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)) {
1052010520 return Ternary.False;
1052110521 }
1052210522
@@ -10545,8 +10545,8 @@ namespace ts {
1054510545 const paramCount = Math.max(sourceCount, targetCount);
1054610546 const lastIndex = paramCount - 1;
1054710547 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);
1055010550 // In order to ensure that any generic type Foo<T> is at least co-variant with respect to T no matter
1055110551 // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions,
1055210552 // they naturally relate only contra-variantly). However, if the source and target parameters both have
@@ -12821,13 +12821,13 @@ namespace ts {
1282112821 sourceHasRest ? targetCount :
1282212822 targetHasRest ? sourceCount :
1282312823 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;
1282612826 for (let i = 0; i < paramCount; i++) {
1282712827 callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
1282812828 }
12829- if (targetRestTypeVariable ) {
12830- callback(getRestTypeAtPosition(source, paramCount), targetRestTypeVariable );
12829+ if (targetGenericRestType ) {
12830+ callback(getRestTypeAtPosition(source, paramCount), targetGenericRestType );
1283112831 }
1283212832 }
1283312833
@@ -18398,8 +18398,8 @@ namespace ts {
1839818398 // We perform two passes over the arguments. In the first pass we infer from all arguments, but use
1839918399 // wildcards for all context sensitive function expressions.
1840018400 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;
1840318403 for (let i = 0; i < argCount; i++) {
1840418404 const arg = getEffectiveArgument(node, args, i);
1840518405 // If the effective argument is 'undefined', then it is an argument that is present but is synthetic.
@@ -18418,9 +18418,9 @@ namespace ts {
1841818418 }
1841918419 }
1842018420
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 );
1842418424 }
1842518425
1842618426 // In the second pass we visit only context sensitive arguments, and only those that aren't excluded, this
@@ -19170,9 +19170,9 @@ namespace ts {
1917019170 }
1917119171 const isJavascript = isInJavaScriptFile(candidate.declaration);
1917219172 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
1917419174 // 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)) {
1917619176 candidateForArgumentArityError = candidate;
1917719177 break;
1917819178 }
@@ -20104,9 +20104,9 @@ namespace ts {
2010420104 const paramCount = getParameterCount(source);
2010520105 const hasRest = hasEffectiveRestParameter(source);
2010620106 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 ;
2011020110 }
2011120111 }
2011220112 const start = hasRest ? Math.min(pos, paramCount - 1) : pos;
@@ -20156,11 +20156,11 @@ namespace ts {
2015620156 return signature.minArgumentCount;
2015720157 }
2015820158
20159- function getRestTypeParameter (signature: Signature) {
20159+ function getGenericRestType (signature: Signature) {
2016020160 if (signature.hasRestParameter) {
2016120161 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;
2016420164 }
2016520165 }
2016620166 return undefined;
0 commit comments