Skip to content

Commit 985051b

Browse files
committed
impl
1 parent e7f571f commit 985051b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/swc_ecma_transformer/src/es2019/optional_catch_binding.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
use swc_ecma_ast::*;
12
use swc_ecma_hooks::VisitMutHook;
3+
use swc_ecma_utils::private_ident;
24

35
use crate::TraverseCtx;
46

@@ -8,4 +10,12 @@ pub fn hook() -> impl VisitMutHook<TraverseCtx> {
810

911
struct OptionalCatchBindingPass {}
1012

11-
impl VisitMutHook<TraverseCtx> for OptionalCatchBindingPass {}
13+
impl VisitMutHook<TraverseCtx> for OptionalCatchBindingPass {
14+
fn enter_catch_clause(&mut self, node: &mut CatchClause, _: &mut TraverseCtx) {
15+
if node.param.is_none() {
16+
// TODO: Do not use private_ident! here.
17+
// All private identifiers should be tracked using TraverseCtx.
18+
node.param = Some(Pat::Ident(private_ident!("unused")));
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)