Skip to content

Commit 0c32a7e

Browse files
committed
fix: do not remove parens for optional params
CLoses #348
1 parent 339a93c commit 0c32a7e

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/generation/generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@ fn gen_arrow_func_expr<'a>(node: &'a ArrowExpr, context: &mut Context<'a>) -> Pr
15871587

15881588
fn is_first_param_not_identifier_or_has_type_annotation(params: &[Pat]) -> bool {
15891589
match params.get(0) {
1590-
Some(Pat::Ident(node)) => node.type_ann.is_some(),
1590+
Some(Pat::Ident(node)) => node.type_ann.is_some() || node.id.optional(),
15911591
_ => true,
15921592
}
15931593
}

tests/specs/expressions/ArrowFunctionExpression/ArrowFunctionExpression_UseParentheses_PreferNone.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ const t = (...a) => 5;
3434

3535
[expect]
3636
const t = (...a) => 5;
37+
38+
== should not remove when optional ==
39+
const t = (a?) => 5;
40+
41+
[expect]
42+
const t = (a?) => 5;

0 commit comments

Comments
 (0)