@@ -18269,6 +18269,32 @@ namespace ts {
18269
18269
}
18270
18270
// Infer from the members of source and target only if the two types are possibly related
18271
18271
if (!typesDefinitelyUnrelated(source, target)) {
18272
+ if (isArrayType(source) || isTupleType(source)) {
18273
+ if (isTupleType(target)) {
18274
+ const sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
18275
+ const targetLength = getLengthOfTupleType(target);
18276
+ const sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
18277
+ const targetRestType = getRestTypeOfTupleType(target);
18278
+ const fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
18279
+ for (let i = 0; i < fixedLength; i++) {
18280
+ inferFromTypes(i < sourceLength ? getTypeArguments(<TypeReference>source)[i] : sourceRestType!, getTypeArguments(target)[i]);
18281
+ }
18282
+ if (targetRestType) {
18283
+ const types = fixedLength < sourceLength ? getTypeArguments(<TypeReference>source).slice(fixedLength, sourceLength) : [];
18284
+ if (sourceRestType) {
18285
+ types.push(sourceRestType);
18286
+ }
18287
+ if (types.length) {
18288
+ inferFromTypes(getUnionType(types), targetRestType);
18289
+ }
18290
+ }
18291
+ return;
18292
+ }
18293
+ if (isArrayType(target)) {
18294
+ inferFromIndexTypes(source, target);
18295
+ return;
18296
+ }
18297
+ }
18272
18298
inferFromProperties(source, target);
18273
18299
inferFromSignatures(source, target, SignatureKind.Call);
18274
18300
inferFromSignatures(source, target, SignatureKind.Construct);
@@ -18277,32 +18303,6 @@ namespace ts {
18277
18303
}
18278
18304
18279
18305
function inferFromProperties(source: Type, target: Type) {
18280
- if (isArrayType(source) || isTupleType(source)) {
18281
- if (isTupleType(target)) {
18282
- const sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0;
18283
- const targetLength = getLengthOfTupleType(target);
18284
- const sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source);
18285
- const targetRestType = getRestTypeOfTupleType(target);
18286
- const fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength;
18287
- for (let i = 0; i < fixedLength; i++) {
18288
- inferFromTypes(i < sourceLength ? getTypeArguments(<TypeReference>source)[i] : sourceRestType!, getTypeArguments(target)[i]);
18289
- }
18290
- if (targetRestType) {
18291
- const types = fixedLength < sourceLength ? getTypeArguments(<TypeReference>source).slice(fixedLength, sourceLength) : [];
18292
- if (sourceRestType) {
18293
- types.push(sourceRestType);
18294
- }
18295
- if (types.length) {
18296
- inferFromTypes(getUnionType(types), targetRestType);
18297
- }
18298
- }
18299
- return;
18300
- }
18301
- if (isArrayType(target)) {
18302
- inferFromIndexTypes(source, target);
18303
- return;
18304
- }
18305
- }
18306
18306
const properties = getPropertiesOfObjectType(target);
18307
18307
for (const targetProp of properties) {
18308
18308
const sourceProp = getPropertyOfType(source, targetProp.escapedName);
0 commit comments