Skip to content

Commit c80f532

Browse files
committed
Add missing check in getTypeAtSwitchClause
1 parent a4a5b38 commit c80f532

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
@@ -14972,9 +14972,12 @@ namespace ts {
1497214972
}
1497314973

1497414974
function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType {
14975+
const expr = flow.switchStatement.expression;
14976+
if (containsMatchingReferenceDiscriminant(reference, expr)) {
14977+
return declaredType;
14978+
}
1497514979
const flowType = getTypeAtFlowNode(flow.antecedent);
1497614980
let type = getTypeFromFlowType(flowType);
14977-
const expr = flow.switchStatement.expression;
1497814981
if (isMatchingReference(reference, expr)) {
1497914982
type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
1498014983
}

0 commit comments

Comments
 (0)