File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -15515,16 +15515,18 @@ namespace ts {
15515
15515
// removing the identically matched constituents. For example, when inferring from
15516
15516
// 'string | string[]' to 'string | T' we reduce the types to 'string[]' and 'T'.
15517
15517
if (matchingTypes) {
15518
- source = removeTypesFromUnionOrIntersection(<UnionOrIntersectionType>source, matchingTypes);
15519
- target = removeTypesFromUnionOrIntersection(<UnionOrIntersectionType>target, matchingTypes);
15518
+ const s = removeTypesFromUnionOrIntersection(<UnionOrIntersectionType>source, matchingTypes);
15519
+ const t = removeTypesFromUnionOrIntersection(<UnionOrIntersectionType>target, matchingTypes);
15520
+ if (!(s && t)) return;
15521
+ source = s;
15522
+ target = t;
15520
15523
}
15521
15524
}
15522
15525
else if (target.flags & TypeFlags.Union && !(target.flags & TypeFlags.EnumLiteral) || target.flags & TypeFlags.Intersection) {
15523
15526
const matched = findMatchedType(source, <UnionOrIntersectionType>target);
15524
15527
if (matched) {
15525
15528
inferFromTypes(matched, matched);
15526
- source = target.flags & TypeFlags.Union ? neverType : unknownType;
15527
- target = removeTypesFromUnionOrIntersection(<UnionOrIntersectionType>target, [matched]);
15529
+ return;
15528
15530
}
15529
15531
}
15530
15532
else if (target.flags & (TypeFlags.IndexedAccess | TypeFlags.Substitution)) {
@@ -15993,7 +15995,7 @@ namespace ts {
15993
15995
reducedTypes.push(t);
15994
15996
}
15995
15997
}
15996
- return type.flags & TypeFlags.Union ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes);
15998
+ return reducedTypes.length ? type.flags & TypeFlags.Union ? getUnionType(reducedTypes) : getIntersectionType(reducedTypes) : undefined ;
15997
15999
}
15998
16000
15999
16001
function hasPrimitiveConstraint(type: TypeParameter): boolean {
You can’t perform that action at this time.
0 commit comments