Rename all proposal plugins to -proposal- from -transform- (#6570)
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
({ a1 } = c1);
|
||||
({ a2, ...b2 } = c2);
|
||||
|
||||
console.log({ a3, ...b3 } = c3);
|
||||
@@ -0,0 +1,14 @@
|
||||
var _c2;
|
||||
|
||||
({
|
||||
a1
|
||||
} = c1);
|
||||
var _c = c2;
|
||||
({
|
||||
a2
|
||||
} = _c);
|
||||
b2 = babelHelpers.objectWithoutProperties(_c, ["a2"]);
|
||||
_c;
|
||||
console.log((_c2 = c3, ({
|
||||
a3
|
||||
} = _c2), b3 = babelHelpers.objectWithoutProperties(_c2, ["a3"]), _c2));
|
||||
@@ -0,0 +1,8 @@
|
||||
try {} catch({ ...a34 }) {}
|
||||
try {} catch({a1, ...b1}) {}
|
||||
try {} catch({a2, b2, ...c2}) {}
|
||||
try {} catch({a2, b2, c2: { c3, ...c4 }}) {}
|
||||
|
||||
// Unchanged
|
||||
try {} catch(a) {}
|
||||
try {} catch({ b }) {}
|
||||
@@ -0,0 +1,36 @@
|
||||
try {} catch (_ref) {
|
||||
let a34 = babelHelpers.objectWithoutProperties(_ref, []);
|
||||
}
|
||||
|
||||
try {} catch (_ref2) {
|
||||
let {
|
||||
a1
|
||||
} = _ref2,
|
||||
b1 = babelHelpers.objectWithoutProperties(_ref2, ["a1"]);
|
||||
}
|
||||
|
||||
try {} catch (_ref3) {
|
||||
let {
|
||||
a2,
|
||||
b2
|
||||
} = _ref3,
|
||||
c2 = babelHelpers.objectWithoutProperties(_ref3, ["a2", "b2"]);
|
||||
}
|
||||
|
||||
try {} catch (_ref4) {
|
||||
let {
|
||||
a2,
|
||||
b2,
|
||||
c2: {
|
||||
c3
|
||||
}
|
||||
} = _ref4,
|
||||
c4 = babelHelpers.objectWithoutProperties(_ref4.c2, ["c3"]);
|
||||
} // Unchanged
|
||||
|
||||
|
||||
try {} catch (a) {}
|
||||
|
||||
try {} catch ({
|
||||
b
|
||||
}) {}
|
||||
5
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/export/actual.js
vendored
Normal file
5
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/export/actual.js
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
// ExportNamedDeclaration
|
||||
export var { b, ...c } = asdf2;
|
||||
// Skip
|
||||
export var { bb, cc } = ads;
|
||||
export var [ dd, ee ] = ads;
|
||||
12
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/export/expected.js
vendored
Normal file
12
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/export/expected.js
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
// ExportNamedDeclaration
|
||||
var {
|
||||
b
|
||||
} = asdf2,
|
||||
c = babelHelpers.objectWithoutProperties(asdf2, ["b"]); // Skip
|
||||
|
||||
export { b, c };
|
||||
export var {
|
||||
bb,
|
||||
cc
|
||||
} = ads;
|
||||
export var [dd, ee] = ads;
|
||||
19
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/for-x/actual.js
vendored
Normal file
19
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/for-x/actual.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// ForXStatement
|
||||
for (var {a, ...b} of []) {}
|
||||
for ({a, ...b} of []) {}
|
||||
async function a() {
|
||||
for await ({a, ...b} of []) {}
|
||||
}
|
||||
|
||||
// skip
|
||||
for ({a} in {}) {}
|
||||
for ({a} of []) {}
|
||||
async function a() {
|
||||
for await ({a} of []) {}
|
||||
}
|
||||
|
||||
for (a in {}) {}
|
||||
for (a of []) {}
|
||||
async function a() {
|
||||
for await (a of []) {}
|
||||
}
|
||||
46
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/for-x/expected.js
vendored
Normal file
46
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/for-x/expected.js
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
// ForXStatement
|
||||
for (var _ref of []) {
|
||||
var {
|
||||
a
|
||||
} = _ref,
|
||||
b = babelHelpers.objectWithoutProperties(_ref, ["a"]);
|
||||
}
|
||||
|
||||
for (var _ref2 of []) {
|
||||
var {
|
||||
a
|
||||
} = _ref2,
|
||||
b = babelHelpers.objectWithoutProperties(_ref2, ["a"]);
|
||||
}
|
||||
|
||||
async function a() {
|
||||
for await (var _ref3 of []) {
|
||||
var {
|
||||
a
|
||||
} = _ref3,
|
||||
b = babelHelpers.objectWithoutProperties(_ref3, ["a"]);
|
||||
}
|
||||
} // skip
|
||||
|
||||
|
||||
for ({
|
||||
a
|
||||
} in {}) {}
|
||||
|
||||
for ({
|
||||
a
|
||||
} of []) {}
|
||||
|
||||
async function a() {
|
||||
for await ({
|
||||
a
|
||||
} of []) {}
|
||||
}
|
||||
|
||||
for (a in {}) {}
|
||||
|
||||
for (a of []) {}
|
||||
|
||||
async function a() {
|
||||
for await (a of []) {}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
var key, x, y, z;
|
||||
// impure
|
||||
key = 1;
|
||||
var { [key++]: y, ...x } = { 1: 1, a: 1 };
|
||||
assert.deepEqual({ a: 1 }, x);
|
||||
assert.equal(key, 2);
|
||||
assert.equal(1, y);
|
||||
|
||||
// takes care of the order
|
||||
|
||||
key = 1;
|
||||
var { [++key]: y, [++key]: z, ...rest} = {2: 2, 3: 3};
|
||||
assert.equal(y, 2);
|
||||
assert.equal(z, 3);
|
||||
|
||||
// pure, computed property should remain as-is
|
||||
key = 2;
|
||||
({ [key]: y, z, ...x } = {2: "two", z: "zee"});
|
||||
assert.equal(y, "two");
|
||||
assert.deepEqual(x, {});
|
||||
assert.equal(z, "zee");
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"minNodeVersion": "6.0.0"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
var key, x, y, z;
|
||||
// impure
|
||||
key = 1;
|
||||
var { [key++]: y, ...x } = { 1: 1, a: 1 };
|
||||
assert.deepEqual({ a: 1 }, x);
|
||||
assert.equal(key, 2);
|
||||
assert.equal(1, y);
|
||||
|
||||
// takes care of the order
|
||||
|
||||
key = 1;
|
||||
var { [++key]: y, [++key]: z, ...rest} = {2: 2, 3: 3};
|
||||
assert.equal(y, 2);
|
||||
assert.equal(z, 3);
|
||||
|
||||
// pure, computed property should remain as-is
|
||||
key = 2;
|
||||
({ [key]: y, z, ...x } = {2: "two", z: "zee"});
|
||||
assert.equal(y, "two");
|
||||
assert.deepEqual(x, {});
|
||||
assert.equal(z, "zee");
|
||||
@@ -0,0 +1,51 @@
|
||||
var key, x, y, z; // impure
|
||||
|
||||
key = 1;
|
||||
|
||||
var _$a = {
|
||||
1: 1,
|
||||
a: 1
|
||||
},
|
||||
_ref = key++,
|
||||
{
|
||||
[_ref]: y
|
||||
} = _$a,
|
||||
x = babelHelpers.objectWithoutProperties(_$a, [_ref].map(babelHelpers.toPropertyKey));
|
||||
|
||||
assert.deepEqual({
|
||||
a: 1
|
||||
}, x);
|
||||
assert.equal(key, 2);
|
||||
assert.equal(1, y); // takes care of the order
|
||||
|
||||
key = 1;
|
||||
|
||||
var _$ = {
|
||||
2: 2,
|
||||
3: 3
|
||||
},
|
||||
_ref2 = ++key,
|
||||
_ref3 = ++key,
|
||||
{
|
||||
[_ref2]: y,
|
||||
[_ref3]: z
|
||||
} = _$,
|
||||
rest = babelHelpers.objectWithoutProperties(_$, [_ref2, _ref3].map(babelHelpers.toPropertyKey));
|
||||
|
||||
assert.equal(y, 2);
|
||||
assert.equal(z, 3); // pure, computed property should remain as-is
|
||||
|
||||
key = 2;
|
||||
var _$z = {
|
||||
2: "two",
|
||||
z: "zee"
|
||||
};
|
||||
({
|
||||
[key]: y,
|
||||
z
|
||||
} = _$z);
|
||||
x = babelHelpers.objectWithoutProperties(_$z, [key, "z"].map(babelHelpers.toPropertyKey));
|
||||
_$z;
|
||||
assert.equal(y, "two");
|
||||
assert.deepEqual(x, {});
|
||||
assert.equal(z, "zee");
|
||||
15
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/nested-2/actual.js
vendored
Normal file
15
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/nested-2/actual.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
const test = {
|
||||
foo: {
|
||||
bar: {
|
||||
baz: {
|
||||
a: {
|
||||
x: 1,
|
||||
y: 2,
|
||||
z: 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const { foo: { bar: { baz: { a: { x, ...other } } } } } = test;
|
||||
25
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/nested-2/expected.js
vendored
Normal file
25
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/nested-2/expected.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
const test = {
|
||||
foo: {
|
||||
bar: {
|
||||
baz: {
|
||||
a: {
|
||||
x: 1,
|
||||
y: 2,
|
||||
z: 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
const {
|
||||
foo: {
|
||||
bar: {
|
||||
baz: {
|
||||
a: {
|
||||
x
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} = test,
|
||||
other = babelHelpers.objectWithoutProperties(test.foo.bar.baz.a, ["x"]);
|
||||
10
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/nested/actual.js
vendored
Normal file
10
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/nested/actual.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
const defunct = {
|
||||
outer: {
|
||||
inner: {
|
||||
three: 'three',
|
||||
four: 'four'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const { outer: { inner: { three, ...other } } } = defunct
|
||||
16
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/nested/expected.js
vendored
Normal file
16
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/nested/expected.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
const defunct = {
|
||||
outer: {
|
||||
inner: {
|
||||
three: 'three',
|
||||
four: 'four'
|
||||
}
|
||||
}
|
||||
};
|
||||
const {
|
||||
outer: {
|
||||
inner: {
|
||||
three
|
||||
}
|
||||
}
|
||||
} = defunct,
|
||||
other = babelHelpers.objectWithoutProperties(defunct.outer.inner, ["three"]);
|
||||
@@ -0,0 +1,54 @@
|
||||
const a = {
|
||||
"3": "three",
|
||||
"foo": "bar"
|
||||
}
|
||||
|
||||
const {
|
||||
[3]: omit,
|
||||
...rest
|
||||
} = a;
|
||||
|
||||
assert.deepEqual(rest, {"foo": "bar"});
|
||||
assert.equal(omit, "three");
|
||||
|
||||
const [k1, k2, k3, k4, k5] = [null, undefined, true, false, {toString() { return "warrior"; }}];
|
||||
const c = {
|
||||
[k1]: "1",
|
||||
[k2]: "2",
|
||||
[k3]: "3",
|
||||
[k4]: "4",
|
||||
[k5]: "5"
|
||||
};
|
||||
|
||||
const {
|
||||
[k1]: v1,
|
||||
[k2]: v2,
|
||||
[k3]: v3,
|
||||
[k4]: v4,
|
||||
[k5]: v5,
|
||||
...vrest
|
||||
} = c;
|
||||
|
||||
assert.equal(v1, "1");
|
||||
assert.equal(v2, "2");
|
||||
assert.equal(v3, "3");
|
||||
assert.equal(v4, "4");
|
||||
assert.equal(v5, "5");
|
||||
assert.deepEqual(vrest, {});
|
||||
|
||||
// shouldn't convert symbols to strings
|
||||
const sx = Symbol();
|
||||
const sy = Symbol();
|
||||
|
||||
const d = {
|
||||
[sx]: "sx",
|
||||
[sy]: "sy"
|
||||
}
|
||||
|
||||
const {
|
||||
[sx]: dx,
|
||||
[sy]: dy
|
||||
} = d;
|
||||
|
||||
assert.equal(dx, "sx");
|
||||
assert.equal(dy, "sy");
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"minNodeVersion": "6.0.0"
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
const a = {
|
||||
"3": "three",
|
||||
"foo": "bar"
|
||||
}
|
||||
|
||||
const {
|
||||
[3]: omit,
|
||||
...rest
|
||||
} = a;
|
||||
|
||||
assert.deepEqual(rest, {"foo": "bar"});
|
||||
assert.equal(omit, "three");
|
||||
|
||||
const [k1, k2, k3, k4, k5] = [null, undefined, true, false, {toString() { return "warrior"; }}];
|
||||
const c = {
|
||||
[k1]: "1",
|
||||
[k2]: "2",
|
||||
[k3]: "3",
|
||||
[k4]: "4",
|
||||
[k5]: "5"
|
||||
};
|
||||
|
||||
const {
|
||||
[k1]: v1,
|
||||
[k2]: v2,
|
||||
[k3]: v3,
|
||||
[k4]: v4,
|
||||
[k5]: v5,
|
||||
...vrest
|
||||
} = c;
|
||||
|
||||
assert.equal(v1, "1");
|
||||
assert.equal(v2, "2");
|
||||
assert.equal(v3, "3");
|
||||
assert.equal(v4, "4");
|
||||
assert.equal(v5, "5");
|
||||
assert.deepEqual(vrest, {});
|
||||
|
||||
// shouldn't convert symbols to strings
|
||||
const sx = Symbol();
|
||||
const sy = Symbol();
|
||||
|
||||
const d = {
|
||||
[sx]: "sx",
|
||||
[sy]: "sy"
|
||||
}
|
||||
|
||||
const {
|
||||
[sx]: dx,
|
||||
[sy]: dy
|
||||
} = d;
|
||||
|
||||
assert.equal(dx, "sx");
|
||||
assert.equal(dy, "sy");
|
||||
@@ -0,0 +1,52 @@
|
||||
const a = {
|
||||
"3": "three",
|
||||
"foo": "bar"
|
||||
};
|
||||
const {
|
||||
[3]: omit
|
||||
} = a,
|
||||
rest = babelHelpers.objectWithoutProperties(a, ["3"]);
|
||||
assert.deepEqual(rest, {
|
||||
"foo": "bar"
|
||||
});
|
||||
assert.equal(omit, "three");
|
||||
const [k1, k2, k3, k4, k5] = [null, undefined, true, false, {
|
||||
toString() {
|
||||
return "warrior";
|
||||
}
|
||||
|
||||
}];
|
||||
const c = {
|
||||
[k1]: "1",
|
||||
[k2]: "2",
|
||||
[k3]: "3",
|
||||
[k4]: "4",
|
||||
[k5]: "5"
|
||||
};
|
||||
const {
|
||||
[k1]: v1,
|
||||
[k2]: v2,
|
||||
[k3]: v3,
|
||||
[k4]: v4,
|
||||
[k5]: v5
|
||||
} = c,
|
||||
vrest = babelHelpers.objectWithoutProperties(c, [k1, k2, k3, k4, k5].map(babelHelpers.toPropertyKey));
|
||||
assert.equal(v1, "1");
|
||||
assert.equal(v2, "2");
|
||||
assert.equal(v3, "3");
|
||||
assert.equal(v4, "4");
|
||||
assert.equal(v5, "5");
|
||||
assert.deepEqual(vrest, {}); // shouldn't convert symbols to strings
|
||||
|
||||
const sx = Symbol();
|
||||
const sy = Symbol();
|
||||
const d = {
|
||||
[sx]: "sx",
|
||||
[sy]: "sy"
|
||||
};
|
||||
const {
|
||||
[sx]: dx,
|
||||
[sy]: dy
|
||||
} = d;
|
||||
assert.equal(dx, "sx");
|
||||
assert.equal(dy, "sy");
|
||||
7
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/options.json
vendored
Normal file
7
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/options.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"plugins": [
|
||||
"syntax-async-generators",
|
||||
"proposal-object-rest-spread",
|
||||
"external-helpers"
|
||||
]
|
||||
}
|
||||
14
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/parameters/actual.js
vendored
Normal file
14
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/parameters/actual.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
function a({ ...a34 }) {}
|
||||
function a2({a1, ...b1}) {}
|
||||
function a3({a2, b2, ...c2}) {}
|
||||
function a4({a3, ...c3}, {a5, ...c5}) {}
|
||||
function a5({a3, b2: { ba1, ...ba2 }, ...c3}) {}
|
||||
function a6({a3, b2: { ba1, ...ba2 } }) {}
|
||||
function a7({a1 = 1, ...b1} = {}) {}
|
||||
function a8([{...a1}]) {}
|
||||
function a9([{a1, ...a2}]) {}
|
||||
function a10([a1, {...a2}]) {}
|
||||
// Unchanged
|
||||
function b(a) {}
|
||||
function b2(a, ...b) {}
|
||||
function b3({ b }) {}
|
||||
@@ -0,0 +1,81 @@
|
||||
function a(_ref) {
|
||||
let a34 = babelHelpers.objectWithoutProperties(_ref, []);
|
||||
}
|
||||
|
||||
function a2(_ref2) {
|
||||
let {
|
||||
a1
|
||||
} = _ref2,
|
||||
b1 = babelHelpers.objectWithoutProperties(_ref2, ["a1"]);
|
||||
}
|
||||
|
||||
function a3(_ref3) {
|
||||
let {
|
||||
a2,
|
||||
b2
|
||||
} = _ref3,
|
||||
c2 = babelHelpers.objectWithoutProperties(_ref3, ["a2", "b2"]);
|
||||
}
|
||||
|
||||
function a4(_ref5, _ref4) {
|
||||
let {
|
||||
a3
|
||||
} = _ref5,
|
||||
c3 = babelHelpers.objectWithoutProperties(_ref5, ["a3"]);
|
||||
let {
|
||||
a5
|
||||
} = _ref4,
|
||||
c5 = babelHelpers.objectWithoutProperties(_ref4, ["a5"]);
|
||||
}
|
||||
|
||||
function a5(_ref6) {
|
||||
let {
|
||||
a3,
|
||||
b2: {
|
||||
ba1
|
||||
}
|
||||
} = _ref6,
|
||||
ba2 = babelHelpers.objectWithoutProperties(_ref6.b2, ["ba1"]),
|
||||
c3 = babelHelpers.objectWithoutProperties(_ref6, ["a3", "b2"]);
|
||||
}
|
||||
|
||||
function a6(_ref7) {
|
||||
let {
|
||||
a3,
|
||||
b2: {
|
||||
ba1
|
||||
}
|
||||
} = _ref7,
|
||||
ba2 = babelHelpers.objectWithoutProperties(_ref7.b2, ["ba1"]);
|
||||
}
|
||||
|
||||
function a7(_ref8 = {}) {
|
||||
let {
|
||||
a1 = 1
|
||||
} = _ref8,
|
||||
b1 = babelHelpers.objectWithoutProperties(_ref8, ["a1"]);
|
||||
}
|
||||
|
||||
function a8([_ref9]) {
|
||||
let a1 = babelHelpers.objectWithoutProperties(_ref9, []);
|
||||
}
|
||||
|
||||
function a9([_ref10]) {
|
||||
let {
|
||||
a1
|
||||
} = _ref10,
|
||||
a2 = babelHelpers.objectWithoutProperties(_ref10, ["a1"]);
|
||||
}
|
||||
|
||||
function a10([a1, _ref11]) {
|
||||
let a2 = babelHelpers.objectWithoutProperties(_ref11, []);
|
||||
} // Unchanged
|
||||
|
||||
|
||||
function b(a) {}
|
||||
|
||||
function b2(a, ...b) {}
|
||||
|
||||
function b3({
|
||||
b
|
||||
}) {}
|
||||
20
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/symbol-exec/exec.js
vendored
Normal file
20
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/symbol-exec/exec.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
const sym = Symbol("test");
|
||||
const sym2 = Symbol("not enumerable");
|
||||
|
||||
const src = { a: "string" };
|
||||
Object.defineProperty(src, "b", { value: "not enumerable" })
|
||||
Object.defineProperty(src, sym, { enumerable: true, value: "symbol" });
|
||||
Object.defineProperty(src, sym2, { value: "not enumerable" });
|
||||
|
||||
const {...rest} = src;
|
||||
|
||||
assert.strictEqual(rest[sym], "symbol");
|
||||
assert.strictEqual(rest.a, "string");
|
||||
assert.deepEqual(Object.getOwnPropertyNames(rest), ["a"]);
|
||||
assert.deepEqual(Object.getOwnPropertySymbols(rest), [sym]);
|
||||
|
||||
const { [sym]: dst, ...noSym } = src;
|
||||
|
||||
assert.strictEqual(dst, "symbol");
|
||||
assert.strictEqual(noSym.a, "string");
|
||||
assert.deepEqual(Object.getOwnPropertySymbols(noSym), []);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": [ "transform-es2015-destructuring", "proposal-object-rest-spread" ]
|
||||
}
|
||||
8
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/symbol/actual.js
vendored
Normal file
8
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/symbol/actual.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
let {
|
||||
[Symbol.for("foo")]: foo,
|
||||
...rest
|
||||
} = {};
|
||||
|
||||
({ [Symbol.for("foo")]: foo, ...rest } = {});
|
||||
|
||||
if ({ [Symbol.for("foo")]: foo, ...rest } = {}) {}
|
||||
22
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/symbol/expected.js
vendored
Normal file
22
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-rest/symbol/expected.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
var _ref3, _Symbol$for3;
|
||||
|
||||
let _ref = {},
|
||||
_Symbol$for = Symbol.for("foo"),
|
||||
{
|
||||
[_Symbol$for]: foo
|
||||
} = _ref,
|
||||
rest = babelHelpers.objectWithoutProperties(_ref, [_Symbol$for].map(babelHelpers.toPropertyKey));
|
||||
|
||||
var _ref2 = {};
|
||||
|
||||
var _Symbol$for2 = Symbol.for("foo");
|
||||
|
||||
({
|
||||
[_Symbol$for2]: foo
|
||||
} = _ref2);
|
||||
rest = babelHelpers.objectWithoutProperties(_ref2, [_Symbol$for2].map(babelHelpers.toPropertyKey));
|
||||
_ref2;
|
||||
|
||||
if (_ref3 = {}, _Symbol$for3 = Symbol.for("foo"), ({
|
||||
[_Symbol$for3]: foo
|
||||
} = _ref3), rest = babelHelpers.objectWithoutProperties(_ref3, [_Symbol$for3].map(babelHelpers.toPropertyKey)), _ref3) {}
|
||||
@@ -0,0 +1,19 @@
|
||||
var z = {};
|
||||
var { ...x } = z;
|
||||
var { ...a } = { a: 1 };
|
||||
var { ...x } = a.b;
|
||||
var { ...x } = a();
|
||||
var {x1, ...y1} = z;
|
||||
x1++;
|
||||
var { [a]: b, ...c } = z;
|
||||
var {x1, ...y1} = z;
|
||||
let {x2, y2, ...z2} = z;
|
||||
const {w3, x3, y3, ...z4} = z;
|
||||
|
||||
let {
|
||||
x: { a: xa, [d]: f, ...asdf },
|
||||
y: { ...d },
|
||||
...g
|
||||
} = complex;
|
||||
|
||||
let { x4: { ...y4 } } = z;
|
||||
@@ -0,0 +1,42 @@
|
||||
var z = {};
|
||||
var x = babelHelpers.objectWithoutProperties(z, []);
|
||||
var a = babelHelpers.objectWithoutProperties({
|
||||
a: 1
|
||||
}, []);
|
||||
var x = babelHelpers.objectWithoutProperties(a.b, []);
|
||||
var x = babelHelpers.objectWithoutProperties(a(), []);
|
||||
var {
|
||||
x1
|
||||
} = z,
|
||||
y1 = babelHelpers.objectWithoutProperties(z, ["x1"]);
|
||||
x1++;
|
||||
var {
|
||||
[a]: b
|
||||
} = z,
|
||||
c = babelHelpers.objectWithoutProperties(z, [a].map(babelHelpers.toPropertyKey));
|
||||
var {
|
||||
x1
|
||||
} = z,
|
||||
y1 = babelHelpers.objectWithoutProperties(z, ["x1"]);
|
||||
let {
|
||||
x2,
|
||||
y2
|
||||
} = z,
|
||||
z2 = babelHelpers.objectWithoutProperties(z, ["x2", "y2"]);
|
||||
const {
|
||||
w3,
|
||||
x3,
|
||||
y3
|
||||
} = z,
|
||||
z4 = babelHelpers.objectWithoutProperties(z, ["w3", "x3", "y3"]);
|
||||
let {
|
||||
x: {
|
||||
a: xa,
|
||||
[d]: f
|
||||
}
|
||||
} = complex,
|
||||
asdf = babelHelpers.objectWithoutProperties(complex.x, ["a", d].map(babelHelpers.toPropertyKey)),
|
||||
d = babelHelpers.objectWithoutProperties(complex.y, []),
|
||||
g = babelHelpers.objectWithoutProperties(complex, ["x"]);
|
||||
let {} = z,
|
||||
y4 = babelHelpers.objectWithoutProperties(z.x4, []);
|
||||
@@ -0,0 +1,22 @@
|
||||
// var { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
|
||||
|
||||
// assert.equal(x, 1);
|
||||
// assert.equal(y, 2);
|
||||
// assert.deepEqual(z, { a: 3, b: 4 });
|
||||
|
||||
// var complex = {
|
||||
// x: { a: 1, b: 2, c: 3 },
|
||||
// };
|
||||
|
||||
// var {
|
||||
// x: { a: xa, ...xbc }
|
||||
// } = complex;
|
||||
|
||||
// assert.equal(xa, 1);
|
||||
// assert.deepEqual(xbc, { b: 2, c: 3});
|
||||
|
||||
// // own properties
|
||||
// function ownX({ ...properties }) {
|
||||
// return properties.x;
|
||||
// }
|
||||
// assert.equal(ownX(Object.create({ x: 1 })), undefined);
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["proposal-object-rest-spread"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
let {
|
||||
a: [b, ...arrayRest],
|
||||
c = function(...functionRest){},
|
||||
...objectRest
|
||||
} = {
|
||||
a: [1, 2, 3, 4],
|
||||
d: "oyez"
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
let _a$d = {
|
||||
a: [1, 2, 3, 4],
|
||||
d: "oyez"
|
||||
},
|
||||
{
|
||||
a: [b, ...arrayRest],
|
||||
c = function (...functionRest) {}
|
||||
} = _a$d,
|
||||
objectRest = babelHelpers.objectWithoutProperties(_a$d, ["a", "c"]);
|
||||
@@ -0,0 +1,3 @@
|
||||
z = { x, ...y };
|
||||
|
||||
z = { x, w: { ...y } };
|
||||
@@ -0,0 +1,9 @@
|
||||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
z = _extends({
|
||||
x
|
||||
}, y);
|
||||
z = {
|
||||
x,
|
||||
w: _extends({}, y)
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
({ x, ...y, a, ...b, c });
|
||||
@@ -0,0 +1,9 @@
|
||||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
_extends({
|
||||
x
|
||||
}, y, {
|
||||
a
|
||||
}, b, {
|
||||
c
|
||||
});
|
||||
3
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/options.json
vendored
Normal file
3
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/object-spread/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["proposal-object-rest-spread"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
var z = { ...x };
|
||||
@@ -0,0 +1,3 @@
|
||||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
var z = _extends({}, x);
|
||||
9
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/T7178/actual.js
vendored
Normal file
9
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/T7178/actual.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import props from "props";
|
||||
|
||||
console.log(props);
|
||||
|
||||
(function(){
|
||||
const { ...props } = this.props;
|
||||
|
||||
console.log(props);
|
||||
})();
|
||||
10
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/T7178/expected.js
vendored
Normal file
10
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/T7178/expected.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
var _props = babelHelpers.interopRequireDefault(require("props"));
|
||||
|
||||
console.log(_props.default);
|
||||
|
||||
(function () {
|
||||
const props = babelHelpers.objectWithoutProperties(this.props, []);
|
||||
console.log(props);
|
||||
})();
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-es2015-modules-commonjs",
|
||||
"transform-es2015-destructuring",
|
||||
"proposal-object-rest-spread",
|
||||
"external-helpers"
|
||||
]
|
||||
}
|
||||
7
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/gh-4904/actual.js
vendored
Normal file
7
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/gh-4904/actual.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
const { s, ...t } = foo();
|
||||
|
||||
const { s: { q1, ...q2 }, ...q3 } = bar();
|
||||
|
||||
const { a } = foo(({ b, ...c }) => {
|
||||
console.log(b, c);
|
||||
});
|
||||
24
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/gh-4904/expected.js
vendored
Normal file
24
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/gh-4904/expected.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
const _foo = foo(),
|
||||
{
|
||||
s
|
||||
} = _foo,
|
||||
t = babelHelpers.objectWithoutProperties(_foo, ["s"]);
|
||||
|
||||
const _bar = bar(),
|
||||
{
|
||||
s: {
|
||||
q1
|
||||
}
|
||||
} = _bar,
|
||||
q2 = babelHelpers.objectWithoutProperties(_bar.s, ["q1"]),
|
||||
q3 = babelHelpers.objectWithoutProperties(_bar, ["s"]);
|
||||
|
||||
const {
|
||||
a
|
||||
} = foo((_ref) => {
|
||||
let {
|
||||
b
|
||||
} = _ref,
|
||||
c = babelHelpers.objectWithoutProperties(_ref, ["b"]);
|
||||
console.log(b, c);
|
||||
});
|
||||
10
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/gh-5151/actual.js
vendored
Normal file
10
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/gh-5151/actual.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
const { x, ...y } = a,
|
||||
z = foo(y);
|
||||
|
||||
const { ...s } = r,
|
||||
t = foo(s);
|
||||
|
||||
// ordering is preserved
|
||||
var l = foo(),
|
||||
{ m: { n, ...o }, ...p } = bar(),
|
||||
q = baz();
|
||||
18
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/gh-5151/expected.js
vendored
Normal file
18
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/gh-5151/expected.js
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
const {
|
||||
x
|
||||
} = a,
|
||||
y = babelHelpers.objectWithoutProperties(a, ["x"]),
|
||||
z = foo(y);
|
||||
const s = babelHelpers.objectWithoutProperties(r, []),
|
||||
t = foo(s); // ordering is preserved
|
||||
|
||||
var l = foo(),
|
||||
_bar = bar(),
|
||||
{
|
||||
m: {
|
||||
n
|
||||
}
|
||||
} = _bar,
|
||||
o = babelHelpers.objectWithoutProperties(_bar.m, ["n"]),
|
||||
p = babelHelpers.objectWithoutProperties(_bar, ["m"]),
|
||||
q = baz();
|
||||
6
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/options.json
vendored
Normal file
6
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/regression/options.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"plugins": [
|
||||
"proposal-object-rest-spread",
|
||||
"external-helpers"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
z = { x, ...y };
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": [["proposal-object-rest-spread", { "useBuiltIns": "invalidOption" }]],
|
||||
"throws": "proposal-object-rest-spread currently only accepts a boolean option for useBuiltIns (defaults to false)"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
z = { x, ...y };
|
||||
@@ -0,0 +1,3 @@
|
||||
z = Object.assign({
|
||||
x
|
||||
}, y);
|
||||
3
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/useBuiltIns/options.json
vendored
Normal file
3
packages/babel-plugin-proposal-object-rest-spread/test/fixtures/useBuiltIns/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": [["proposal-object-rest-spread", { "useBuiltIns": true }]]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import runner from "@babel/helper-plugin-test-runner";
|
||||
|
||||
runner(__dirname);
|
||||
Reference in New Issue
Block a user