Add missing check in getTypeAtSwitchClause

This commit is contained in:
Anders Hejlsberg
2018-10-08 09:59:47 -07:00
parent a4a5b3806e
commit c80f532e01

View File

@@ -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);
}