Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix rewriteThis in helper-module-transforms for computed class… (#11109)
* Fix rewriteThis in helper-module-transforms for computed class elements * Added test file and corrected the visitor * Revert .gitignore * Using skipAllButComputedKey method from plugin-replace-supers * added tests for class methods * Added tests for both class properties and methods and fixed skipping computed key for methods * Fixed condition for class methods * revised the conditions for class methods * Added more tests and used else-if in classmethod condition * Update packages/babel-helper-replace-supers/src/index.js Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com> Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
- Loading branch information
1 parent
3fc904e
commit 3c6a8ae
Showing
15 changed files
with
81 additions
and
3 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
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
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
1 change: 1 addition & 0 deletions
1
...form-modules-commonjs/test/fixtures/misc/undefined-this-computed-class-method-1/input.mjs
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 @@ | ||
export class C { [this.name]() {} } |
7 changes: 7 additions & 0 deletions
7
...m-modules-commonjs/test/fixtures/misc/undefined-this-computed-class-method-1/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": [ | ||
"external-helpers", | ||
"transform-modules-commonjs", | ||
"syntax-class-properties" | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
...form-modules-commonjs/test/fixtures/misc/undefined-this-computed-class-method-1/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,13 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.C = void 0; | ||
|
||
class C { | ||
[(void 0).name]() {} | ||
|
||
} | ||
|
||
exports.C = C; |
3 changes: 3 additions & 0 deletions
3
...form-modules-commonjs/test/fixtures/misc/undefined-this-computed-class-method-2/input.mjs
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,3 @@ | ||
class A { | ||
[() => this.name]() {} | ||
} |
7 changes: 7 additions & 0 deletions
7
...m-modules-commonjs/test/fixtures/misc/undefined-this-computed-class-method-2/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": [ | ||
"external-helpers", | ||
"transform-modules-commonjs", | ||
"syntax-class-properties" | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
...form-modules-commonjs/test/fixtures/misc/undefined-this-computed-class-method-2/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,6 @@ | ||
"use strict"; | ||
|
||
class A { | ||
[() => (void 0).name]() {} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
...form-modules-commonjs/test/fixtures/misc/undefined-this-computed-class-method-3/input.mjs
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,3 @@ | ||
class A { | ||
[function () { this.name; }]() {} | ||
} |
7 changes: 7 additions & 0 deletions
7
...m-modules-commonjs/test/fixtures/misc/undefined-this-computed-class-method-3/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": [ | ||
"external-helpers", | ||
"transform-modules-commonjs", | ||
"syntax-class-properties" | ||
] | ||
} |
8 changes: 8 additions & 0 deletions
8
...form-modules-commonjs/test/fixtures/misc/undefined-this-computed-class-method-3/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,8 @@ | ||
"use strict"; | ||
|
||
class A { | ||
[function () { | ||
this.name; | ||
}]() {} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
...modules-commonjs/test/fixtures/misc/undefined-this-computed-class-property-name/input.mjs
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 @@ | ||
export class C { [this.name] = 42 } |
7 changes: 7 additions & 0 deletions
7
...ules-commonjs/test/fixtures/misc/undefined-this-computed-class-property-name/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": [ | ||
"external-helpers", | ||
"transform-modules-commonjs", | ||
"syntax-class-properties" | ||
] | ||
} |
12 changes: 12 additions & 0 deletions
12
...modules-commonjs/test/fixtures/misc/undefined-this-computed-class-property-name/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,12 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.C = void 0; | ||
|
||
class C { | ||
[(void 0).name] = 42; | ||
} | ||
|
||
exports.C = C; |