Fix handling of class property value this in module transforms. (#9857)
Prevent module transforms from rewriting `this` to `void 0` when found in the values of private class properties. Add tests to prevent regressions.
This commit is contained in:
parent
e4072752bc
commit
f31c72f310
@ -17,4 +17,7 @@ const rewriteThisVisitor = {
|
||||
ClassProperty(path) {
|
||||
path.skip();
|
||||
},
|
||||
ClassPrivateProperty(path) {
|
||||
path.skip();
|
||||
},
|
||||
};
|
||||
|
||||
6
packages/babel-plugin-transform-modules-commonjs/test/fixtures/class-properties/options.json
vendored
Normal file
6
packages/babel-plugin-transform-modules-commonjs/test/fixtures/class-properties/options.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"parserOpts": {
|
||||
"plugins": ["classProperties", "classPrivateProperties", "classPrivateMethods"]
|
||||
},
|
||||
"plugins": ["transform-modules-commonjs"]
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
class Example {
|
||||
#method() {
|
||||
console.log(this);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
class Example {
|
||||
#method() {
|
||||
console.log(this);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
class Example {
|
||||
#property = this;
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
class Example {
|
||||
#property = this;
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
class Example {
|
||||
property = this;
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
class Example {
|
||||
property = this;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user