From ba30fdc4ae961298d1ac6a3e0b6fc3d1ac1c0e74 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 18 Sep 2019 06:36:51 -0700 Subject: [PATCH] Attach flow nodes only when allowUnreachableCode !== true --- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index cf93ee17eb..c9d3d15b9a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -672,7 +672,7 @@ namespace ts { bindJSDoc(node); return; } - if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement) { + if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9e331dd085..7e9e8bd4b0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -30539,8 +30539,7 @@ namespace ts { cancellationToken.throwIfCancellationRequested(); } } - if (kind >= SyntaxKind.FirstStatement && kind <= SyntaxKind.LastStatement && - !compilerOptions.allowUnreachableCode && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= SyntaxKind.FirstStatement && kind <= SyntaxKind.LastStatement && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, Diagnostics.Unreachable_code_detected); }