@@ -17922,6 +17922,32 @@ namespace ts {
1792217922 }
1792317923 // Infer from the members of source and target only if the two types are possibly related
1792417924 if (!typesDefinitelyUnrelated(source, target)) {
17925+ if (isArrayType(source) || isTupleType(source)) {
17926+ if (isTupleType(target)) {
17927+ const sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
17928+ const targetLength = getLengthOfTupleType(target);
17929+ const sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
17930+ const targetRestType = getRestTypeOfTupleType(target);
17931+ const fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
17932+ for (let i = 0; i < fixedLength; i++) {
17933+ inferFromTypes(i < sourceLength ? getTypeArguments(<TypeReference>source)[i] : sourceRestType!, getTypeArguments(target)[i]);
17934+ }
17935+ if (targetRestType) {
17936+ const types = fixedLength < sourceLength ? getTypeArguments(<TypeReference>source).slice(fixedLength, sourceLength) : [];
17937+ if (sourceRestType) {
17938+ types.push(sourceRestType);
17939+ }
17940+ if (types.length) {
17941+ inferFromTypes(getUnionType(types), targetRestType);
17942+ }
17943+ }
17944+ return;
17945+ }
17946+ if (isArrayType(target)) {
17947+ inferFromIndexTypes(source, target);
17948+ return;
17949+ }
17950+ }
1792517951 inferFromProperties(source, target);
1792617952 inferFromSignatures(source, target, SignatureKind.Call);
1792717953 inferFromSignatures(source, target, SignatureKind.Construct);
@@ -17930,32 +17956,6 @@ namespace ts {
1793017956 }
1793117957
1793217958 function inferFromProperties(source: Type, target: Type) {
17933- if (isArrayType(source) || isTupleType(source)) {
17934- if (isTupleType(target)) {
17935- const sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
17936- const targetLength = getLengthOfTupleType(target);
17937- const sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
17938- const targetRestType = getRestTypeOfTupleType(target);
17939- const fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
17940- for (let i = 0; i < fixedLength; i++) {
17941- inferFromTypes(i < sourceLength ? getTypeArguments(<TypeReference>source)[i] : sourceRestType!, getTypeArguments(target)[i]);
17942- }
17943- if (targetRestType) {
17944- const types = fixedLength < sourceLength ? getTypeArguments(<TypeReference>source).slice(fixedLength, sourceLength) : [];
17945- if (sourceRestType) {
17946- types.push(sourceRestType);
17947- }
17948- if (types.length) {
17949- inferFromTypes(getUnionType(types), targetRestType);
17950- }
17951- }
17952- return;
17953- }
17954- if (isArrayType(target)) {
17955- inferFromIndexTypes(source, target);
17956- return;
17957- }
17958- }
1795917959 const properties = getPropertiesOfObjectType(target);
1796017960 for (const targetProp of properties) {
1796117961 const sourceProp = getPropertyOfType(source, targetProp.escapedName);
0 commit comments