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

Null coalescing operator combined with "||" or "&&" #410

Open
jbakic opened this issue Nov 13, 2024 · 1 comment
Open

Null coalescing operator combined with "||" or "&&" #410

jbakic opened this issue Nov 13, 2024 · 1 comment

Comments

@jbakic
Copy link

jbakic commented Nov 13, 2024

Hello! I am getting this syntax error in the browser after minification with NUglify: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_use_nullish_coalescing_unparenthesized

The original line looks like this:
return (this.props.infoText ?? "") || _message.default.getFormatter("dxPager-infoText")()

And it gets minified to this:
return this.props.infoText??""||l.default.getFormatter("dxPager-infoText")()

The above line of code is the only line in a certain function.

As you can see, the brackets around the "??" and its operands were removed. The MDN article claims that the precedence order between the operator "??" and the operators "||" and "&&" is deliberately undefined, so the removal of these brackets seems to be an error.

@trullock
Copy link
Owner

Thanks for the report

Should be a simple fix, cant remember exactly where but in the analysers maybe it sees if operators need parenthesis or not, probably just need to switch a false for a true

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