Skip to content

Commit

Permalink
experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-williams committed Nov 19, 2019
1 parent b31b417 commit 356b91d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19311,6 +19311,7 @@ namespace ts {

function getTypeAtFlowBranchLabel(flow: FlowLabel): FlowType {
const antecedentTypes: Type[] = [];
const containedUnions: Type[] = [];
let subtypeReduction = false;
let seenIncomplete = false;
for (const antecedent of flow.antecedents!) {
Expand All @@ -19330,6 +19331,7 @@ namespace ts {
return type;
}
pushIfUnique(antecedentTypes, type);
pushIfUnique(containedUnions, containingUnion || type);
// If an antecedent type is not a subset of the declared type, we need to perform
// subtype reduction. This happens when a "foreign" type is injected into the control
// flow using the instanceof operator or a user defined type predicate.
Expand All @@ -19340,6 +19342,8 @@ namespace ts {
seenIncomplete = true;
}
}
const containingUnionType = createFlowType(getUnionOrEvolvingArrayType(containedUnions, subtypeReduction ? UnionReduction.Subtype : UnionReduction.Literal), seenIncomplete);
captureContainingUnion(containingUnionType);
return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? UnionReduction.Subtype : UnionReduction.Literal), seenIncomplete);
}

Expand Down

0 comments on commit 356b91d

Please sign in to comment.