Skip to content

Commit 74d3e2a

Browse files
Generalize to intersection types when looking for discriminants in error reporting.
1 parent 69affb7 commit 74d3e2a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12533,8 +12533,8 @@ namespace ts {
1253312533

1253412534
// Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly
1253512535
function findMatchingDiscriminantType(source: Type, target: Type) {
12536-
if (target.flags & TypeFlags.Union) {
12537-
const sourceProperties = getPropertiesOfObjectType(source);
12536+
if (target.flags & TypeFlags.Union && source.flags & (TypeFlags.Intersection | TypeFlags.Object)) {
12537+
const sourceProperties = getPropertiesOfType(source);
1253812538
if (sourceProperties) {
1253912539
const sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
1254012540
if (sourcePropertiesFiltered) {

0 commit comments

Comments
 (0)