File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -11182,7 +11182,8 @@ namespace ts {
11182
11182
if (reportErrors) {
11183
11183
const bestMatchingType =
11184
11184
findMatchingDiscriminantType(source, target) ||
11185
- findMatchingTypeReferenceOrTypeAliasReference(source, target);
11185
+ findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
11186
+ findBestTypeForObjectLiteral(source, target);
11186
11187
11187
11188
isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true);
11188
11189
}
@@ -11207,6 +11208,11 @@ namespace ts {
11207
11208
}
11208
11209
}
11209
11210
11211
+ function findBestTypeForObjectLiteral(source: Type, unionTarget: UnionOrIntersectionType) {
11212
+ if (getObjectFlags(source) & ObjectFlags.ObjectLiteral && forEachType(unionTarget, isArrayLikeType)) {
11213
+ return find(unionTarget.types, t => !isArrayLikeType(t));
11214
+ }
11215
+ }
11210
11216
11211
11217
// Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly
11212
11218
function findMatchingDiscriminantType(source: Type, target: UnionOrIntersectionType) {
You can’t perform that action at this time.
0 commit comments