@@ -18373,6 +18373,32 @@ namespace ts {
1837318373 }
1837418374 // Infer from the members of source and target only if the two types are possibly related
1837518375 if (!typesDefinitelyUnrelated(source, target)) {
18376+ if (isArrayType(source) || isTupleType(source)) {
18377+ if (isTupleType(target)) {
18378+ const sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
18379+ const targetLength = getLengthOfTupleType(target);
18380+ const sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
18381+ const targetRestType = getRestTypeOfTupleType(target);
18382+ const fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
18383+ for (let i = 0; i < fixedLength; i++) {
18384+ inferFromTypes(i < sourceLength ? getTypeArguments(<TypeReference>source)[i] : sourceRestType!, getTypeArguments(target)[i]);
18385+ }
18386+ if (targetRestType) {
18387+ const types = fixedLength < sourceLength ? getTypeArguments(<TypeReference>source).slice(fixedLength, sourceLength) : [];
18388+ if (sourceRestType) {
18389+ types.push(sourceRestType);
18390+ }
18391+ if (types.length) {
18392+ inferFromTypes(getUnionType(types), targetRestType);
18393+ }
18394+ }
18395+ return;
18396+ }
18397+ if (isArrayType(target)) {
18398+ inferFromIndexTypes(source, target);
18399+ return;
18400+ }
18401+ }
1837618402 inferFromProperties(source, target);
1837718403 inferFromSignatures(source, target, SignatureKind.Call);
1837818404 inferFromSignatures(source, target, SignatureKind.Construct);
@@ -18381,32 +18407,6 @@ namespace ts {
1838118407 }
1838218408
1838318409 function inferFromProperties(source: Type, target: Type) {
18384- if (isArrayType(source) || isTupleType(source)) {
18385- if (isTupleType(target)) {
18386- const sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
18387- const targetLength = getLengthOfTupleType(target);
18388- const sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
18389- const targetRestType = getRestTypeOfTupleType(target);
18390- const fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
18391- for (let i = 0; i < fixedLength; i++) {
18392- inferFromTypes(i < sourceLength ? getTypeArguments(<TypeReference>source)[i] : sourceRestType!, getTypeArguments(target)[i]);
18393- }
18394- if (targetRestType) {
18395- const types = fixedLength < sourceLength ? getTypeArguments(<TypeReference>source).slice(fixedLength, sourceLength) : [];
18396- if (sourceRestType) {
18397- types.push(sourceRestType);
18398- }
18399- if (types.length) {
18400- inferFromTypes(getUnionType(types), targetRestType);
18401- }
18402- }
18403- return;
18404- }
18405- if (isArrayType(target)) {
18406- inferFromIndexTypes(source, target);
18407- return;
18408- }
18409- }
1841018410 const properties = getPropertiesOfObjectType(target);
1841118411 for (const targetProp of properties) {
1841218412 const sourceProp = getPropertyOfType(source, targetProp.escapedName);
0 commit comments