forked from babel/babel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to whitelist specific property/function names to use lo…
…ose mode when transforming destructuring
- Loading branch information
Showing
5 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...ansform-destructuring/test/fixtures/destructuring/es7-object-rest-selective-loose/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const useState = () => (["state", "dispatch"]); | ||
|
||
var [state, dispatch] = useState(); | ||
|
||
expect(state).toBe("state"); | ||
expect(dispatch).toBe("dispatch"); |
9 changes: 9 additions & 0 deletions
9
...nsform-destructuring/test/fixtures/destructuring/es7-object-rest-selective-loose/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var z = {}; | ||
var { ...x } = z; | ||
var { x, ...y } = z; | ||
var { [x]: x, ...y } = z; | ||
(function({ x, ...y }) { }); | ||
|
||
({ x, y, ...z } = o); | ||
|
||
var [state, dispatch] = useState(); |
7 changes: 7 additions & 0 deletions
7
...rm-destructuring/test/fixtures/destructuring/es7-object-rest-selective-loose/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"plugins": [ | ||
["transform-destructuring", { "selectiveLoose": ["z", "useState"] }], | ||
"proposal-object-rest-spread", | ||
["external-helpers", { "helperVersion": "7.1.5" }] | ||
] | ||
} |
24 changes: 24 additions & 0 deletions
24
...sform-destructuring/test/fixtures/destructuring/es7-object-rest-selective-loose/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var z = {}; | ||
var _z = z, | ||
x = babelHelpers.extends({}, _z); | ||
var _z2 = z, | ||
x = _z2.x, | ||
y = babelHelpers.objectWithoutPropertiesLoose(_z2, ["x"]); | ||
var _z3 = z, | ||
x = _z3[x], | ||
y = babelHelpers.objectWithoutPropertiesLoose(_z3, [x].map(babelHelpers.toPropertyKey)); | ||
|
||
(function (_ref) { | ||
let x = _ref.x, | ||
y = babelHelpers.objectWithoutProperties(_ref, ["x"]); | ||
}); | ||
|
||
var _o = o; | ||
x = _o.x; | ||
y = _o.y; | ||
z = babelHelpers.objectWithoutProperties(_o, ["x", "y"]); | ||
|
||
var _useState = useState(), | ||
_useState2 = babelHelpers.slicedToArray(_useState, 2), | ||
state = _useState2[0], | ||
dispatch = _useState2[1]; |