@@ -18301,6 +18301,32 @@ namespace ts {
1830118301 }
1830218302 // Infer from the members of source and target only if the two types are possibly related
1830318303 if (!typesDefinitelyUnrelated(source, target)) {
18304+ if (isArrayType(source) || isTupleType(source)) {
18305+ if (isTupleType(target)) {
18306+ const sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
18307+ const targetLength = getLengthOfTupleType(target);
18308+ const sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
18309+ const targetRestType = getRestTypeOfTupleType(target);
18310+ const fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
18311+ for (let i = 0; i < fixedLength; i++) {
18312+ inferFromTypes(i < sourceLength ? getTypeArguments(<TypeReference>source)[i] : sourceRestType!, getTypeArguments(target)[i]);
18313+ }
18314+ if (targetRestType) {
18315+ const types = fixedLength < sourceLength ? getTypeArguments(<TypeReference>source).slice(fixedLength, sourceLength) : [];
18316+ if (sourceRestType) {
18317+ types.push(sourceRestType);
18318+ }
18319+ if (types.length) {
18320+ inferFromTypes(getUnionType(types), targetRestType);
18321+ }
18322+ }
18323+ return;
18324+ }
18325+ if (isArrayType(target)) {
18326+ inferFromIndexTypes(source, target);
18327+ return;
18328+ }
18329+ }
1830418330 inferFromProperties(source, target);
1830518331 inferFromSignatures(source, target, SignatureKind.Call);
1830618332 inferFromSignatures(source, target, SignatureKind.Construct);
@@ -18309,32 +18335,6 @@ namespace ts {
1830918335 }
1831018336
1831118337 function inferFromProperties(source: Type, target: Type) {
18312- if (isArrayType(source) || isTupleType(source)) {
18313- if (isTupleType(target)) {
18314- const sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
18315- const targetLength = getLengthOfTupleType(target);
18316- const sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
18317- const targetRestType = getRestTypeOfTupleType(target);
18318- const fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
18319- for (let i = 0; i < fixedLength; i++) {
18320- inferFromTypes(i < sourceLength ? getTypeArguments(<TypeReference>source)[i] : sourceRestType!, getTypeArguments(target)[i]);
18321- }
18322- if (targetRestType) {
18323- const types = fixedLength < sourceLength ? getTypeArguments(<TypeReference>source).slice(fixedLength, sourceLength) : [];
18324- if (sourceRestType) {
18325- types.push(sourceRestType);
18326- }
18327- if (types.length) {
18328- inferFromTypes(getUnionType(types), targetRestType);
18329- }
18330- }
18331- return;
18332- }
18333- if (isArrayType(target)) {
18334- inferFromIndexTypes(source, target);
18335- return;
18336- }
18337- }
1833818338 const properties = getPropertiesOfObjectType(target);
1833918339 for (const targetProp of properties) {
1834018340 const sourceProp = getPropertyOfType(source, targetProp.escapedName);
0 commit comments