minify icon indicating copy to clipboard operation
minify copied to clipboard

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

Open knu opened this issue 6 years ago • 0 comments

To Reproduce

Minimal code to reproduce the bug

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

// 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

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

Possible solution

Additional context

knu avatar Aug 06 '19 07:08 knu