Fixed narrowing in case clauses that follow other clauses that return (#56358)

This commit is contained in:
Mateusz Burzyński authored and GitHub committed 2023-11-13 14:41:56 -08:00
1 parent 70becf9af9
commit 9f15002959
4 files changed
+357

No files matched your search

+4
View File
@@ -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++;
}