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

Optional Chaining: unable to apply further transforms to certain function call arguments #8212

Closed
microbouji opened this issue Jun 22, 2018 · 2 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@microbouji
Copy link
Member

Bug Report

Current Behavior
The following input code throws "Container is falsy"

Input Code

a?.b(2 ** 3)

Expected behavior/code

(_a = a) === null || _a === void 0 ? void 0 : _a.b(Math.pow(2, 3));

Babel Configuration (.babelrc, package.json, cli command)

{
  "plugins": [
    "@babel/transform-exponentiation-operator",
    "@babel/proposal-optional-chaining"
  ]
}

Order doesn't matter.

Environment

  • Babel version(s): v7.0.0-beta.51
  • Node/npm version: Node 8.10.0 / npm 5.6.0
  • OS: Ubuntu 16.04
  • Monorepo [e.g. yes/no/Lerna]
  • How you are using Babel: [e.g. cli, register, loader]

Possible Solution

Additional context/Screenshots
a?.(2 ** 3) works fine. So I think it only happens when the result of findReplacementPath is not the same as path itself in https://github.com/babel/babel/blob/master/packages/babel-plugin-proposal-optional-chaining/src/index.js#L138

The exponentiation operator is just one case. It also throws with template literals for example

a?.b(`foo`)

Looks like it might be a caching thing. While debugging with the node debugger, the path that transform-template-literals was trying to replace had indeed container set to null but it fixed itself after I ran something like parentPath.get('arguments') or similar in the debug console just to see what was going on.

@babel-bot
Copy link
Collaborator

Hey @microbouji! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@microbouji
Copy link
Member Author

Closing this as it's working now. Was most probably fixed by #9073.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Feb 25, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 25, 2019
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
Projects
None yet
Development

No branches or pull requests

2 participants