Skip to content

Commit 9e4995c

Browse files
committed
fix(codegen): print type annotation on CatchParameter (#19790)
1 parent 297b2bb commit 9e4995c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

crates/oxc_codegen/src/gen.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ impl Gen for CatchClause<'_> {
604604
p.print_soft_space();
605605
p.print_ascii_byte(b'(');
606606
param.pattern.print(p, ctx);
607+
if let Some(type_annotation) = &param.type_annotation {
608+
p.print_colon();
609+
p.print_soft_space();
610+
type_annotation.print(p, ctx);
611+
}
607612
p.print_ascii_byte(b')');
608613
}
609614
p.print_soft_space();

crates/oxc_codegen/tests/integration/ts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ fn cases() {
3636
test_same("class E {\n\tsubscribe!: string;\n}\n");
3737
test_same("class F {\n\taccessor value!: string;\n}\n");
3838
test_same("export { type as as };\n");
39+
test_same("try {} catch (e: unknown) {} finally {}\n");
3940
}
4041

4142
#[test]

0 commit comments

Comments
 (0)