Skip to content

Commit 148a494

Browse files
committed
Adds transformers for ignored catch parameter
1 parent b917eb0 commit 148a494

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/compiler/transformers/es2015.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3173,7 +3173,7 @@ namespace ts {
31733173
function visitCatchClause(node: CatchClause): CatchClause {
31743174
const ancestorFacts = enterSubtree(HierarchyFacts.BlockScopeExcludes, HierarchyFacts.BlockScopeIncludes);
31753175
let updated: CatchClause;
3176-
if (isBindingPattern(node.variableDeclaration.name)) {
3176+
if (node.variableDeclaration && isBindingPattern(node.variableDeclaration.name)) {
31773177
const temp = createTempVariable(/*recordTempVariable*/ undefined);
31783178
const newVariableDeclaration = createVariableDeclaration(temp);
31793179
setTextRange(newVariableDeclaration, node.variableDeclaration);

src/compiler/transformers/esnext.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ namespace ts {
101101
return visitExpressionStatement(node as ExpressionStatement);
102102
case SyntaxKind.ParenthesizedExpression:
103103
return visitParenthesizedExpression(node as ParenthesizedExpression, noDestructuringValue);
104+
case SyntaxKind.CatchClause:
105+
return visitCatchClause(node as CatchClause);
104106
default:
105107
return visitEachChild(node, visitor, context);
106108
}
@@ -212,6 +214,13 @@ namespace ts {
212214
return visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context);
213215
}
214216

217+
function visitCatchClause(node: CatchClause): CatchClause {
218+
if (!node.variableDeclaration) {
219+
return updateCatchClause(node, createVariableDeclaration("_ignoredCatchParameter"), node.block);
220+
}
221+
return visitEachChild(node, visitor, context);
222+
}
223+
215224
/**
216225
* Visits a BinaryExpression that contains a destructuring assignment.
217226
*

0 commit comments

Comments
 (0)