(node)
| 47681 | return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); |
| 47682 | } |
| 47683 | function checkUnreachable(node) { |
| 47684 | if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { |
| 47685 | return false; |
| 47686 | } |
| 47687 | if (currentFlow === unreachableFlow) { |
| 47688 | var reportError = |
| 47689 | // report error on all statements except empty ones |
| 47690 | (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || |
| 47691 | // report error on class declarations |
| 47692 | node.kind === 257 /* SyntaxKind.ClassDeclaration */ || |
| 47693 | // report error on instantiated modules or const-enums only modules if preserveConstEnums is set |
| 47694 | (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); |
| 47695 | if (reportError) { |
| 47696 | currentFlow = reportedUnreachableFlow; |
| 47697 | if (!options.allowUnreachableCode) { |
| 47698 | // unreachable code is reported if |
| 47699 | // - user has explicitly asked about it AND |
| 47700 | // - statement is in not ambient context (statements in ambient context is already an error |
| 47701 | // so we should not report extras) AND |
| 47702 | // - node is not variable statement OR |
| 47703 | // - node is block scoped variable statement OR |
| 47704 | // - node is not block scoped variable statement and at least one variable declaration has initializer |
| 47705 | // Rationale: we don't want to report errors on non-initialized var's since they are hoisted |
| 47706 | // On the other side we do want to report errors on non-initialized 'lets' because of TDZ |
| 47707 | var isError_1 = ts.unreachableCodeIsError(options) && |
| 47708 | !(node.flags & 16777216 /* NodeFlags.Ambient */) && |
| 47709 | (!ts.isVariableStatement(node) || |
| 47710 | !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || |
| 47711 | node.declarationList.declarations.some(function (d) { return !!d.initializer; })); |
| 47712 | eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); |
| 47713 | } |
| 47714 | } |
| 47715 | } |
| 47716 | return true; |
| 47717 | } |
| 47718 | } |
| 47719 | function eachUnreachableRange(node, cb) { |
| 47720 | if (ts.isStatement(node) && isExecutableStatement(node) && ts.isBlock(node.parent)) { |
no test coverage detected