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

Remove empty destructuring #1498

Open
bbrk24 opened this issue Feb 27, 2024 · 2 comments
Open

Remove empty destructuring #1498

bbrk24 opened this issue Feb 27, 2024 · 2 comments

Comments

@bbrk24
Copy link

bbrk24 commented Feb 27, 2024

Bug report or Feature request?

Feature request

Version (complete output of terser -V or specific git commit)

5.27.2

Complete CLI command or minify() options used

npx terser in.js -o out.js --ecma 13 -f wrap_func_args=false -c unsafe=true,unsafe_arrows=true

terser input

const [,] = m;

terser output or error

const[,]=m;

Expected result

I understand why this can't be done by default, but it would be nice if there were a compress option to remove declarations that don't actually declare anything. This statement is generated by an upstream compiler (Civet 0.6.82, MWE), and in the context of the program I know that the iterator is pure and this statement is safe to drop.

@fabiosantoscode
Copy link
Collaborator

I never implemented this because it's not usually safe to do. If m is undefined, that's a TypeError. But of course, it's possible to do if we know it's iterable, or if the user passed some unsafe_xxx option signaling they're okay with being a bit loose with this.

@bbrk24
Copy link
Author

bbrk24 commented Mar 6, 2024

Yeah -- as in the linked example code, this only ever happens in my code in a block guarded by Array.isArray(m), so I know it's safe in my case. And I totally understand if it needs to be locked behind an unsafe compress option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants