@@ -27352,8 +27352,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2735227352 const constraint = param && getBaseConstraintOfType(param);
2735327353 if (constraint && isTupleType(constraint) && !(constraint.target.combinedFlags & ElementFlags.Variable)) {
2735427354 const impliedArity = constraint.target.fixedLength;
27355- inferFromTypes(sliceTupleType(source, startLength, sourceArity - (startLength + impliedArity)), elementTypes[startLength]);
27356- inferFromTypes(getElementTypeOfSliceOfTupleType(source, startLength + impliedArity, endLength)!, elementTypes[startLength + 1]);
27355+ if (startLength + impliedArity <= source.target.fixedLength) {
27356+ inferFromTypes(sliceTupleType(source, startLength, sourceArity - (startLength + impliedArity)), elementTypes[startLength]);
27357+ inferFromTypes(getElementTypeOfSliceOfTupleType(source, startLength + impliedArity, endLength)!, elementTypes[startLength + 1]);
27358+ }
2735727359 }
2735827360 }
2735927361 else if (elementFlags[startLength] & ElementFlags.Rest && elementFlags[startLength + 1] & ElementFlags.Variadic) {
@@ -27363,12 +27365,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2736327365 const constraint = param && getBaseConstraintOfType(param);
2736427366 if (constraint && isTupleType(constraint) && !(constraint.target.combinedFlags & ElementFlags.Variable)) {
2736527367 const impliedArity = constraint.target.fixedLength;
27366- const endIndex = sourceArity - getEndElementCount(target.target, ElementFlags.Fixed);
27367- const startIndex = endIndex - impliedArity;
27368- const trailingSlice = createTupleType(getTypeArguments(source).slice(startIndex, endIndex), source.target.elementFlags.slice(startIndex, endIndex), /*readonly*/ false, source.target.labeledElementDeclarations && source.target.labeledElementDeclarations.slice(startIndex, endIndex));
27368+ if (endLength + impliedArity <= getEndElementCount(source.target, ElementFlags.Fixed)) {
27369+ const endIndex = sourceArity - getEndElementCount(target.target, ElementFlags.Fixed);
27370+ const startIndex = endIndex - impliedArity;
27371+ const trailingSlice = createTupleType(getTypeArguments(source).slice(startIndex, endIndex), source.target.elementFlags.slice(startIndex, endIndex), /*readonly*/ false, source.target.labeledElementDeclarations && source.target.labeledElementDeclarations.slice(startIndex, endIndex));
2736927372
27370- inferFromTypes(getElementTypeOfSliceOfTupleType(source, startLength, endLength + impliedArity)!, elementTypes[startLength]);
27371- inferFromTypes(trailingSlice, elementTypes[startLength + 1]);
27373+ inferFromTypes(getElementTypeOfSliceOfTupleType(source, startLength, endLength + impliedArity)!, elementTypes[startLength]);
27374+ inferFromTypes(trailingSlice, elementTypes[startLength + 1]);
27375+ }
2737227376 }
2737327377 }
2737427378 }
0 commit comments