Skip to content

Commit

Permalink
Added test file and corrected the visitor
Browse files Browse the repository at this point in the history
  • Loading branch information
sidntrivedi012 committed Feb 8, 2020
1 parent 5a7c3d8 commit b822bd0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/babel-helper-module-transforms/src/rewrite-this.js
@@ -1,5 +1,3 @@
import { classMethod } from "@babel/types";

export default function rewriteThis(programPath: NodePath) {
// Rewrite "this" to be "undefined".
programPath.traverse(rewriteThisVisitor);
Expand All @@ -17,9 +15,13 @@ const rewriteThisVisitor = {
if (!path.isArrowFunctionExpression()) path.skip();
},
ClassProperty(path) {
classMethod(path);
path.skip();
},
ClassMethod(path) {
if (path.node.computed) {
//requeue the key child of classProperty here
}
},
ClassPrivateProperty(path) {
path.skip();
},
Expand Down
@@ -0,0 +1 @@
export class C { [this.name] = 42 }
@@ -0,0 +1,7 @@
{
"plugins": [
"external-helpers",
"transform-modules-commonjs",
"@babel/plugin-proposal-class-properties"
]
}

0 comments on commit b822bd0

Please sign in to comment.