mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Fixed narrowing in case clauses that follow other clauses that return (#56358)
This commit is contained in:
1 parent
70becf9af9
commit
9f15002959
4 files changed
+357
No files matched your search
@@ -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