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

Logical assignment operators; Fix parsing of optional chaining #1888

Closed
gilad905 opened this issue Feb 23, 2021 · 4 comments
Closed

Logical assignment operators; Fix parsing of optional chaining #1888

gilad905 opened this issue Feb 23, 2021 · 4 comments

Comments

@gilad905
Copy link

gilad905 commented Feb 23, 2021

  1. Add support for logical OR/AND/nullish assignment operators
  2. Fix incorrect parsing of optional chaining when followed by a bracket notation.

Input - expected output should not change

  let a;
  a ||= 1;
  a &&= 2;
  a ??= 3;
  const b = a?.[keyName];

Actual (not expected) output

  let a;
  a || = 1;
  a && = 2;
  a ?? = 3;
  const b = a?. [keyName];

P.S.
I've opened a PR for the logical operators support. It failed one of the automated tests, although if you look at the commit it's clear the commit didn't trigger the fail because the changes are very minor.

Thanks!

@gilad905
Copy link
Author

I realized now that the beutifying of #2 still results in valid code. But I would still suggest to change it because I believe it is less readable.

@bitwiseman
Copy link
Member

Javascript doesn't contain a ||= operator.
https://262.ecma-international.org/5.1/#sec-7.7

I assume that this es6, much like ?..

Note, const b = a?.[keyName]; remains unchanged on https://beautifier.io . Are you using an editor plugin?

@gilad905
Copy link
Author

gilad905 commented Mar 2, 2021

yes, I'm using atom-beautify

@mhnaeem
Copy link
Contributor

mhnaeem commented Apr 7, 2022

Fixed in #1991

@bitwiseman bitwiseman added this to the v1.14.0 milestone Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants