Skip to content

Don't add parens when arrow function is part of a default assign#1540

Merged
fabiosantoscode merged 1 commit intoterser:masterfrom
Nefsen402:default-assign
Jun 25, 2024
Merged

Don't add parens when arrow function is part of a default assign#1540
fabiosantoscode merged 1 commit intoterser:masterfrom
Nefsen402:default-assign

Conversation

@Nefsen402
Copy link
Copy Markdown
Contributor

In the case of this code snippet:

const myFunction = (callback = () => {}) {
  callback();
}

Terser would insert parenthesis in the default parameter like this:

const myFunction = (callback = (() => {})) {
  callback();
}

They aren't needed, so don't generate them.

Nefsen402 added a commit to Nefsen402/destam-dom that referenced this pull request Jun 24, 2024
…ual files

This lets us implement additional tricks. Note that this does not yet
generate an optimal output because of:
terser/terser#1540
@fabiosantoscode
Copy link
Copy Markdown
Collaborator

Thank you very much!

@fabiosantoscode fabiosantoscode merged commit cc7ac7c into terser:master Jun 25, 2024
@Nefsen402 Nefsen402 deleted the default-assign branch June 25, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants