Skip to content

Hole array spread inside of another array isn't work correctly #8874

@macabeus

Description

@macabeus

Bug Report

Current Behavior
If we spread an array with hole ([1,, 2] of new Array(3), for example), the code generated from Babel don't convert the holes to undefined.

Input Code
Using babel, this code

[1, ...[2,, 3]]

generates this:

[1].concat([2,, 3]) // returns [1, 4, (empty), 3]

Expected behavior/code

[1, ...[2,, 3]] // should returns [1, 2, undefined, 3]

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

{
  plugins: ["@babel/plugin-transform-spread"]
}

Environment

  • Babel version(s): lasted version from git
  • Node/npm version: Node v9, NPM 5.6.0
  • OS: macOS High Sierra
  • Monorepo: yep
  • How you are using Babel: CLI

Additional context/Screenshots
I found this bug when I'm doing this PR for fix a similar bug: #8872
This PR isn't fix this another bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions