(result, errorLocation)
| 50294 | return false; |
| 50295 | } |
| 50296 | function checkResolvedBlockScopedVariable(result, errorLocation) { |
| 50297 | var _a; |
| 50298 | ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); |
| 50299 | if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { |
| 50300 | // constructor functions aren't block scoped |
| 50301 | return; |
| 50302 | } |
| 50303 | // Block-scoped variables cannot be used before their definition |
| 50304 | var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); |
| 50305 | if (declaration === undefined) |
| 50306 | return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); |
| 50307 | if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { |
| 50308 | var diagnosticMessage = void 0; |
| 50309 | var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); |
| 50310 | if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { |
| 50311 | diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); |
| 50312 | } |
| 50313 | else if (result.flags & 32 /* SymbolFlags.Class */) { |
| 50314 | diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); |
| 50315 | } |
| 50316 | else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { |
| 50317 | diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); |
| 50318 | } |
| 50319 | else { |
| 50320 | ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); |
| 50321 | if (ts.shouldPreserveConstEnums(compilerOptions)) { |
| 50322 | diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); |
| 50323 | } |
| 50324 | } |
| 50325 | if (diagnosticMessage) { |
| 50326 | ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here, declarationName)); |
| 50327 | } |
| 50328 | } |
| 50329 | } |
| 50330 | /* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached. |
| 50331 | * If at any point current node is equal to 'parent' node - return true. |
| 50332 | * If current node is an IIFE, continue walking up. |
no test coverage detected