Add "allowArrayLike" opt to destructuring and spread transforms (#11265)
This commit is contained in:
6
packages/babel-plugin-transform-destructuring/test/fixtures/allowArrayLike/simple/exec.js
vendored
Normal file
6
packages/babel-plugin-transform-destructuring/test/fixtures/allowArrayLike/simple/exec.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
var o = { 0: "a", 1: "b", 2: "c", length: 3 };
|
||||
|
||||
var [first, ...rest] = o;
|
||||
|
||||
expect(first).toBe("a");
|
||||
expect(rest).toEqual(["b", "c"]);
|
||||
1
packages/babel-plugin-transform-destructuring/test/fixtures/allowArrayLike/simple/input.js
vendored
Normal file
1
packages/babel-plugin-transform-destructuring/test/fixtures/allowArrayLike/simple/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
var [first, ...rest] = o;
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
["external-helpers", { "helperVersion": "7.100.0" }],
|
||||
["transform-destructuring", { "allowArrayLike": true }]
|
||||
]
|
||||
}
|
||||
4
packages/babel-plugin-transform-destructuring/test/fixtures/allowArrayLike/simple/output.js
vendored
Normal file
4
packages/babel-plugin-transform-destructuring/test/fixtures/allowArrayLike/simple/output.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var _o = o,
|
||||
_o2 = babelHelpers.maybeArrayLike(babelHelpers.toArray, _o),
|
||||
first = _o2[0],
|
||||
rest = _o2.slice(1);
|
||||
Reference in New Issue
Block a user