diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 852bf39c16d..c37066858a0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14972,9 +14972,12 @@ namespace ts { } function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType { + const expr = flow.switchStatement.expression; + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } const flowType = getTypeAtFlowNode(flow.antecedent); let type = getTypeFromFlowType(flowType); - const expr = flow.switchStatement.expression; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }