diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 20dbc7962fa..1a901806dfa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17052,10 +17052,13 @@ namespace ts { else if (flags & FlowFlags.Assignment) { type = getTypeAtFlowAssignment(flow); if (!type) { - flow = (flow).antecedent; - continue; + if (!(flags & FlowFlags.Shared)) { + flow = (flow).antecedent; + continue; + } + type = getTypeAtFlowNode((flow).antecedent); } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis + if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis const key = getOrSetCacheKey(); if (key && !isIncomplete(type)) { flow.flags |= FlowFlags.Cached; @@ -17073,18 +17076,26 @@ namespace ts { } else if (flags & FlowFlags.Label) { if ((flow).antecedents!.length === 1) { - flow = (flow).antecedents![0]; - continue; + if (!(flags & FlowFlags.Shared)) { + flow = (flow).antecedents![0]; + continue; + } + type = getTypeAtFlowNode((flow).antecedents![0]); + } + else { + type = flags & FlowFlags.BranchLabel ? + getTypeAtFlowBranchLabel(flow) : + getTypeAtFlowLoopLabel(flow); } - type = flags & FlowFlags.BranchLabel ? - getTypeAtFlowBranchLabel(flow) : - getTypeAtFlowLoopLabel(flow); } else if (flags & FlowFlags.ArrayMutation) { type = getTypeAtFlowArrayMutation(flow); if (!type) { - flow = (flow).antecedent; - continue; + if (!(flags & FlowFlags.Shared)) { + flow = (flow).antecedent; + continue; + } + type = getTypeAtFlowNode((flow).antecedent); } } else if (flags & FlowFlags.Start) {