Recognize object rest properties as binding identifiers - fixes T7178
This commit is contained in:
9
packages/babel-plugin-transform-object-rest-spread/test/fixtures/regression/T7178/actual.js
vendored
Normal file
9
packages/babel-plugin-transform-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);
|
||||
})();
|
||||
17
packages/babel-plugin-transform-object-rest-spread/test/fixtures/regression/T7178/expected.js
vendored
Normal file
17
packages/babel-plugin-transform-object-rest-spread/test/fixtures/regression/T7178/expected.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
var _props = require("props");
|
||||
|
||||
var _props2 = _interopRequireDefault(_props);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
|
||||
|
||||
console.log(_props2.default);
|
||||
|
||||
(function () {
|
||||
const props = _objectWithoutProperties(this.props, []);
|
||||
|
||||
console.log(props);
|
||||
})();
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"plugins": [
|
||||
"transform-es2015-modules-commonjs",
|
||||
"transform-es2015-destructuring",
|
||||
"transform-object-rest-spread"
|
||||
]
|
||||
}
|
||||
@@ -91,7 +91,7 @@ getBindingIdentifiers.keys = {
|
||||
RestElement: ["argument"],
|
||||
UpdateExpression: ["argument"],
|
||||
|
||||
SpreadProperty: ["argument"],
|
||||
RestProperty: ["argument"],
|
||||
ObjectProperty: ["value"],
|
||||
|
||||
AssignmentPattern: ["left"],
|
||||
|
||||
Reference in New Issue
Block a user