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