Implement MemberExpressionToFunctions helper (#7763)

* Implement MemberExpressionToFunctions helper

Fixes #7733.

This will also be used to simplify the Private Fields transform, which had [almost the same code](ccd941057a/packages/babel-plugin-proposal-class-properties/src/index.js (L114-L217)) hand written.

* Cleanup

* Little more comment cleanup

* Use unary plus

This can't be redefined, unlike the `Number` identifier.

* Review comments

* Remove unused deps
This commit is contained in:
Justin Ridgewell
2018-04-21 13:13:42 -04:00
committed by GitHub
parent dbdce0e4e4
commit 8f24f91166
11 changed files with 252 additions and 213 deletions

View File

@@ -29,7 +29,7 @@ function (_Point) {
babelHelpers.classCallCheck(this, ColorPoint);
_this = babelHelpers.possibleConstructorReturn(this, babelHelpers.getPrototypeOf(ColorPoint).call(this));
_this.x = 2;
babelHelpers.set(babelHelpers.getPrototypeOf(ColorPoint.prototype), "x", 3, _this, true)
babelHelpers.set(babelHelpers.getPrototypeOf(ColorPoint.prototype), "x", 3, _this, true);
expect(_this.x).toBe(3); // A
expect(babelHelpers.get(babelHelpers.getPrototypeOf(ColorPoint.prototype), "x", babelHelpers.assertThisInitialized(_this))).toBeUndefined(); // B