Skip to content

Commit 356b91d

Browse files
committed
experiment
1 parent b31b417 commit 356b91d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19311,6 +19311,7 @@ namespace ts {
1931119311

1931219312
function getTypeAtFlowBranchLabel(flow: FlowLabel): FlowType {
1931319313
const antecedentTypes: Type[] = [];
19314+
const containedUnions: Type[] = [];
1931419315
let subtypeReduction = false;
1931519316
let seenIncomplete = false;
1931619317
for (const antecedent of flow.antecedents!) {
@@ -19330,6 +19331,7 @@ namespace ts {
1933019331
return type;
1933119332
}
1933219333
pushIfUnique(antecedentTypes, type);
19334+
pushIfUnique(containedUnions, containingUnion || type);
1933319335
// If an antecedent type is not a subset of the declared type, we need to perform
1933419336
// subtype reduction. This happens when a "foreign" type is injected into the control
1933519337
// flow using the instanceof operator or a user defined type predicate.
@@ -19340,6 +19342,8 @@ namespace ts {
1934019342
seenIncomplete = true;
1934119343
}
1934219344
}
19345+
const containingUnionType = createFlowType(getUnionOrEvolvingArrayType(containedUnions, subtypeReduction ? UnionReduction.Subtype : UnionReduction.Literal), seenIncomplete);
19346+
captureContainingUnion(containingUnionType);
1934319347
return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? UnionReduction.Subtype : UnionReduction.Literal), seenIncomplete);
1934419348
}
1934519349

0 commit comments

Comments
 (0)