Skip to content

Commit

Permalink
feat(typescript-estree): throw error when CatchClause param contains …
Browse files Browse the repository at this point in the history
…initializer (#8183)
  • Loading branch information
auvred committed Jan 4, 2024
1 parent ca00388 commit 544fd77
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
try {
}
catch (e = 1) {
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/typescript-estree/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,12 @@ export class Converter {
});

case SyntaxKind.CatchClause:
if (node.variableDeclaration?.initializer) {
this.#throwError(
node.variableDeclaration.initializer,
'Catch clause variable cannot have an initializer.',
);
}
return this.createNode<TSESTree.CatchClause>(node, {
type: AST_NODE_TYPES.CatchClause,
param: node.variableDeclaration
Expand Down

0 comments on commit 544fd77

Please sign in to comment.