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

Fix transform of delete a?.b in function params #15739

Merged

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Jul 3, 2023

Q                       A
Fixed Issues? Fixes #15738
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Please review commit-by-commit.

The first one splits the existing transform logic in two parts, without causing any observable change:

  1. how to, in general, traverse and transform an optional chain (moved to the transformOptionalChain function)
  2. how the output should change depending on whether the optional chain is in a "read" context or in a "delete context". This will make it incredibly easy to implement a?.b = c in the future, which I'm presenting at the next TC39 meeting

The second commit actually fixes the bug, that I found while working on a?.b = c because function f(x = a?.b = c) {} was also broken.

@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Jul 3, 2023
@babel-bot
Copy link
Collaborator

babel-bot commented Jul 3, 2023

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54745/

@nicolo-ribaudo nicolo-ribaudo merged commit 2952d76 into babel:main Jul 4, 2023
54 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the optional-chaining-refactor branch July 4, 2023 05:09
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Optional Chaining
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Invalid transfor for optional chain delete in function params
4 participants