Attach flow nodes only when allowUnreachableCode !== true

This commit is contained in:
Anders Hejlsberg 2019-09-18 06:36:51 -07:00
parent 9466025996
commit ba30fdc4ae
2 changed files with 2 additions and 3 deletions

View file

@ -672,7 +672,7 @@ namespace ts {
bindJSDoc(node); bindJSDoc(node);
return; return;
} }
if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement) { if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement && !options.allowUnreachableCode) {
node.flowNode = currentFlow; node.flowNode = currentFlow;
} }
switch (node.kind) { switch (node.kind) {

View file

@ -30539,8 +30539,7 @@ namespace ts {
cancellationToken.throwIfCancellationRequested(); cancellationToken.throwIfCancellationRequested();
} }
} }
if (kind >= SyntaxKind.FirstStatement && kind <= SyntaxKind.LastStatement && if (kind >= SyntaxKind.FirstStatement && kind <= SyntaxKind.LastStatement && node.flowNode && !isReachableFlowNode(node.flowNode)) {
!compilerOptions.allowUnreachableCode && node.flowNode && !isReachableFlowNode(node.flowNode)) {
errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, Diagnostics.Unreachable_code_detected); errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, Diagnostics.Unreachable_code_detected);
} }