Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parser): Handle trailing comma and bracket after arrow fn in conditional in TS #3685

Merged
2 changes: 1 addition & 1 deletion crates/swc_ecma_parser/src/parser/expr.rs
Expand Up @@ -707,7 +707,7 @@ impl<'a, I: Tokens> Parser<I> {
params.is_simple_parameter_list(),
)?;

if is_direct_child_of_cond && !is_one_of!(p, ':', ';') {
if is_direct_child_of_cond && !is_one_of!(p, ':', ';', ',') {
trace_cur!(p, parse_arrow_in_cond__fail);
unexpected!(p, "fail")
}
Expand Down
11 changes: 11 additions & 0 deletions crates/swc_ecma_parser/src/parser/expr/tests.rs
Expand Up @@ -494,6 +494,17 @@ fn super_expr_computed() {
);
}

#[test]
fn issue_3672() {
test_parser(
"report({
fix: fixable ? null : (): RuleFix => {},
});",
Syntax::Typescript(Default::default()),
|p| p.parse_module(),
);
}

#[bench]
fn bench_new_expr_ts(b: &mut Bencher) {
bench_parser(
Expand Down