File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11182,7 +11182,8 @@ namespace ts {
1118211182 if (reportErrors) {
1118311183 const bestMatchingType =
1118411184 findMatchingDiscriminantType(source, target) ||
11185- findMatchingTypeReferenceOrTypeAliasReference(source, target);
11185+ findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
11186+ findBestTypeForObjectLiteral(source, target);
1118611187
1118711188 isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true);
1118811189 }
@@ -11207,6 +11208,11 @@ namespace ts {
1120711208 }
1120811209 }
1120911210
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+ }
1121011216
1121111217 // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly
1121211218 function findMatchingDiscriminantType(source: Type, target: UnionOrIntersectionType) {
You can’t perform that action at this time.
0 commit comments