babel / babel/minify

simplify expands a return value of Object.entries() to void 0

Open
#962 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

**To Reproduce**

Minimal code to reproduce the bug

```js
function unLoad() {
const { events } = this.props;
const { editor } = this.state;
if (!editor) return;

const { change, ...eventsSansChange } = events;
for (const [event, handler] of Object.entries(eventsSansChange)) {
editor.on(event, handler);
}
}
```

**Actual Output**

```js
// bootstrap and polyfill snipped
function unLoad() {
var a = this.props.events,
b = this.state.editor;
if (b)
for (
var c = a.change,
d = _objectWithoutProperties(a, ["change"]),
e = 0,
f = Object.entries(d);
e < (void 0).length;
e++
) {
var g = _slicedToArray((void 0)[e], 2),
h = g[0],
i = g[1];
b.on(h, i);
}
}
```

**Expected Output**

`f` should not expand to `void 0`.

**Configuration**

How are you using babel-minify?

- babel-preset-minify 0.5.0 via webpack 4.39.1

- a complete reproduction: https://gist.github.com/knu/cf52dfed7bdf5b00d5e204e6de3cbe53

```json5
{
plugins: [],
presets: [
["@babel/preset-env", { modules: false }],
["minify", { builtIns: false }]
]
}
```

**Possible solution**

**Additional context**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.