Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
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 delete must return true when base is nullish #10805

Closed
jridgewell opened this issue Dec 3, 2019 · 2 comments · Fixed by #10806
Closed

Optional delete must return true when base is nullish #10805

jridgewell opened this issue Dec 3, 2019 · 2 comments · Fixed by #10806

Comments

@jridgewell
Copy link
Member

@jridgewell jridgewell commented Dec 3, 2019

Bug Report

Current Behavior

When using optional delete to delete a property of a nullish base, the delete operation returns undefined. It should return true

Input Code
repl

let foo;
const ret = delete foo?.bar;

console.assert(ret === true);

Expected behavior/code
The ret value should be true, not undefined.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
{
  "plugins": ["@babel/plugin-proposal-optional-chaining"]
}

Possible Solution
When replacing optional deletes, we must use t.booleanLiteral(true) in the consequent (truthy branch of a ternary expression) instead of scope.buildUndefinedNode().

Specifically, we must fix

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@mpaarating

This comment has been minimized.

Copy link
Contributor

@mpaarating mpaarating commented Dec 3, 2019

I can look at this!

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Dec 3, 2019

Sure, it's yours!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.