MCPcopy Index your code
hub / github.com/nodejs/node / checkTryStatement

Function checkTryStatement

test/fixtures/snapshot/typescript.js:83770–83806  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

83768 }
83769 }
83770 function checkTryStatement(node) {
83771 // Grammar checking
83772 checkGrammarStatementInAmbientContext(node);
83773 checkBlock(node.tryBlock);
83774 var catchClause = node.catchClause;
83775 if (catchClause) {
83776 // Grammar checking
83777 if (catchClause.variableDeclaration) {
83778 var declaration = catchClause.variableDeclaration;
83779 var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration));
83780 if (typeNode) {
83781 var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */);
83782 if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) {
83783 grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
83784 }
83785 }
83786 else if (declaration.initializer) {
83787 grammarErrorOnFirstToken(declaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer);
83788 }
83789 else {
83790 var blockLocals_1 = catchClause.block.locals;
83791 if (blockLocals_1) {
83792 ts.forEachKey(catchClause.locals, function (caughtName) {
83793 var blockLocal = blockLocals_1.get(caughtName);
83794 if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) {
83795 grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName);
83796 }
83797 });
83798 }
83799 }
83800 }
83801 checkBlock(catchClause.block);
83802 }
83803 if (node.finallyBlock) {
83804 checkBlock(node.finallyBlock);
83805 }
83806 }
83807 function checkIndexConstraints(type, symbol, isStaticIndex) {
83808 var indexInfos = getIndexInfosOfType(type);
83809 if (indexInfos.length === 0) {

Callers 1

checkSourceElementWorkerFunction · 0.85

Calls 6

checkBlockFunction · 0.85
grammarErrorOnFirstTokenFunction · 0.85
grammarErrorOnNodeFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…