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