Skip to content

Commit e91ee14

Browse files
committed
Only perform fallback when computed type is not an intersection or union
1 parent e130cd6 commit e91ee14

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16184,7 +16184,10 @@ namespace ts {
1618416184
}
1618516185
let propType;
1618616186
return isMatchingReference(reference, expr.expression) &&
16187-
(isDiscriminantProperty(computedType, name) || (propType = getTypeOfPropertyOfType(computedType, name)) && isUnitType(propType));
16187+
(isDiscriminantProperty(computedType, name) ||
16188+
((computedType.flags & TypeFlags.UnionOrIntersection) === 0) &&
16189+
(propType = getTypeOfPropertyOfType(computedType, name))
16190+
&& isUnitType(propType));
1618816191
}
1618916192

1619016193
function narrowTypeByDiscriminant(type: Type, access: AccessExpression, narrowType: (t: Type) => Type): Type {

0 commit comments

Comments
 (0)