New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
environmentVisitor should skip decorator expressions #14371
Changes from 1 commit
92c1fe2
cd36e00
79d47ae
8dcfb17
6965de6
0402111
72bfe40
cd342f2
a0480fc
2f10492
791d2f4
6157204
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ let Outer = /*#__PURE__*/function (_Hello) { | |
var _this; | ||
|
||
babelHelpers.classCallCheck(this, Outer); | ||
_dec = _this = _super.call(this) | ||
_dec = _this = _super.call(this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know why this line is changed after rebasing. Maybe a generator update? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #14398 probably |
||
let Inner = /*#__PURE__*/babelHelpers.createClass(function Inner() { | ||
babelHelpers.classCallCheck(this, Inner); | ||
babelHelpers.defineProperty(this, "hello", _init_hello(this)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
class Hello { | ||
toString() { | ||
return 'hello'; | ||
} | ||
} | ||
|
||
class Outer extends Hello { | ||
constructor() { | ||
super(); | ||
class Inner { | ||
accessor [super.toString()] = 'hello'; | ||
} | ||
|
||
return new Inner(); | ||
} | ||
} | ||
|
||
expect(new Outer().hello).toBe('hello'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"use strict"; | ||
class Hello { | ||
toString() { | ||
return 'hello'; | ||
} | ||
} | ||
|
||
class Outer extends Hello { | ||
constructor() { | ||
super(); | ||
class Inner { | ||
accessor [super.toString()] = 'hello'; | ||
} | ||
|
||
return new Inner(); | ||
} | ||
} | ||
|
||
expect(new Outer().hello).toBe('hello'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"plugins": [ | ||
["proposal-decorators", { "version": "2021-12" }], | ||
"proposal-class-static-block", | ||
"proposal-class-properties", | ||
"transform-classes" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"use strict"; | ||
|
||
let Hello = /*#__PURE__*/function () { | ||
function Hello() { | ||
babelHelpers.classCallCheck(this, Hello); | ||
} | ||
|
||
babelHelpers.createClass(Hello, [{ | ||
key: "toString", | ||
value: function toString() { | ||
return 'hello'; | ||
} | ||
}]); | ||
return Hello; | ||
}(); | ||
|
||
let Outer = /*#__PURE__*/function (_Hello) { | ||
babelHelpers.inherits(Outer, _Hello); | ||
|
||
var _super = babelHelpers.createSuper(Outer); | ||
|
||
function Outer() { | ||
let _babelHelpers$get$cal, _babelHelpers$get$cal2; | ||
|
||
var _thisSuper, _this; | ||
|
||
babelHelpers.classCallCheck(this, Outer); | ||
_this = _super.call(this); | ||
|
||
var _A = /*#__PURE__*/new WeakMap(); | ||
|
||
_babelHelpers$get$cal = babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Outer.prototype)), "toString", _thisSuper).call(_thisSuper); | ||
_babelHelpers$get$cal2 = babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(Outer.prototype)), "toString", _thisSuper).call(_thisSuper); | ||
|
||
let Inner = /*#__PURE__*/function () { | ||
function Inner() { | ||
babelHelpers.classCallCheck(this, Inner); | ||
babelHelpers.classPrivateFieldInitSpec(this, _A, { | ||
writable: true, | ||
value: 'hello' | ||
}); | ||
} | ||
|
||
babelHelpers.createClass(Inner, [{ | ||
key: _babelHelpers$get$cal, | ||
get: function () { | ||
return babelHelpers.classPrivateFieldGet(this, _A); | ||
} | ||
}, { | ||
key: _babelHelpers$get$cal2, | ||
set: function (v) { | ||
babelHelpers.classPrivateFieldSet(this, _A, v); | ||
} | ||
}]); | ||
return Inner; | ||
}(); | ||
|
||
return babelHelpers.possibleConstructorReturn(_this, new Inner()); | ||
} | ||
|
||
return babelHelpers.createClass(Outer); | ||
}(Hello); | ||
|
||
expect(new Outer().hello).toBe('hello'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -502,7 +502,7 @@ function transformClass( | |
if (element.node.decorators && element.node.decorators.length > 0) { | ||
hasElementDecorators = true; | ||
} else if (element.node.type === "ClassAccessorProperty") { | ||
const { key, value, static: isStatic } = element.node; | ||
const { key, value, static: isStatic, computed } = element.node; | ||
|
||
const newId = generateClassPrivateUid(); | ||
|
||
|
@@ -511,7 +511,7 @@ function transformClass( | |
const newField = generateClassProperty(newId, valueNode, isStatic); | ||
|
||
const [newPath] = element.replaceWith(newField); | ||
addProxyAccessorsFor(newPath, key, newId, element.node.computed); | ||
addProxyAccessorsFor(newPath, key, newId, computed); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bug fix, the |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The visitor now hooks on
Property
alias so that it supports older@babel/types
withoutClassAccessorProperty
definitions.