Skip to content

Commit f40f0db

Browse files
committed
Preserve intersections on the source side in type inference
1 parent e51e91d commit f40f0db

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/compiler/checker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10578,7 +10578,7 @@ namespace ts {
1057810578
priority = savePriority;
1057910579
}
1058010580
}
10581-
else if (source.flags & TypeFlags.UnionOrIntersection) {
10581+
else if (source.flags & TypeFlags.Union) {
1058210582
// Source is a union or intersection type, infer from each constituent type
1058310583
const sourceTypes = (<UnionOrIntersectionType>source).types;
1058410584
for (const sourceType of sourceTypes) {
@@ -10587,7 +10587,7 @@ namespace ts {
1058710587
}
1058810588
else {
1058910589
source = getApparentType(source);
10590-
if (source.flags & TypeFlags.Object) {
10590+
if (source.flags & (TypeFlags.Object | TypeFlags.Intersection)) {
1059110591
const key = source.id + "," + target.id;
1059210592
if (visited && visited.get(key)) {
1059310593
return;
@@ -10667,7 +10667,7 @@ namespace ts {
1066710667
function inferFromProperties(source: Type, target: Type) {
1066810668
const properties = getPropertiesOfObjectType(target);
1066910669
for (const targetProp of properties) {
10670-
const sourceProp = getPropertyOfObjectType(source, targetProp.escapedName);
10670+
const sourceProp = getPropertyOfType(source, targetProp.escapedName);
1067110671
if (sourceProp) {
1067210672
inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
1067310673
}

0 commit comments

Comments
 (0)