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

This commit is contained in:
Mateusz Burzyński
2023-11-13 14:41:56 -08:00
committed by GitHub
parent 70becf9af9
commit 9f15002959
4 changed files with 357 additions and 0 deletions
+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++;
}