mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fixed narrowing in case clauses that follow other clauses that return (#56358)
This commit is contained in:
@@ -1689,9 +1689,13 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
|
||||
const clauses = node.clauses;
|
||||
const isNarrowingSwitch = node.parent.expression.kind === SyntaxKind.TrueKeyword || isNarrowingExpression(node.parent.expression);
|
||||
let fallthroughFlow = unreachableFlow;
|
||||
|
||||
for (let i = 0; i < clauses.length; i++) {
|
||||
const clauseStart = i;
|
||||
while (!clauses[i].statements.length && i + 1 < clauses.length) {
|
||||
if (fallthroughFlow === unreachableFlow) {
|
||||
currentFlow = preSwitchCaseFlow!;
|
||||
}
|
||||
bind(clauses[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user