File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -11395,7 +11395,8 @@ namespace ts {
11395
11395
const bestMatchingType =
11396
11396
findMatchingDiscriminantType(source, target) ||
11397
11397
findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
11398
- findBestTypeForObjectLiteral(source, target);
11398
+ findBestTypeForObjectLiteral(source, target) ||
11399
+ findBestTypeForInvokable(source, target);
11399
11400
11400
11401
isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], /*reportErrors*/ true);
11401
11402
}
@@ -11426,6 +11427,15 @@ namespace ts {
11426
11427
}
11427
11428
}
11428
11429
11430
+ function findBestTypeForInvokable(source: Type, unionTarget: UnionOrIntersectionType) {
11431
+ let signatureKind = SignatureKind.Call;
11432
+ const hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 ||
11433
+ (signatureKind = SignatureKind.Construct, getSignaturesOfType(source, signatureKind).length > 0);
11434
+ if (hasSignatures) {
11435
+ return find(unionTarget.types, t => getSignaturesOfType(t, signatureKind).length > 0);
11436
+ }
11437
+ }
11438
+
11429
11439
// Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly
11430
11440
function findMatchingDiscriminantType(source: Type, target: UnionOrIntersectionType) {
11431
11441
let match: Type | undefined;
You can’t perform that action at this time.
0 commit comments