Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
Create a variable for class properties in scope instead of deleting t…
Browse files Browse the repository at this point in the history
…he key (#336)
  • Loading branch information
hzoo committed Jul 8, 2016
1 parent 2d72002 commit 254e6ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 0 additions & 5 deletions babylon-to-espree/toAST.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ var astTransformVisitor = {
}
}

// remove class property keys (or patch in escope)
if (path.isClassProperty()) {
delete node.key;
}

// async function as generator
if (path.isFunction()) {
if (node.async) node.generator = true;
Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ function monkeypatch() {
// visit decorators that are in: ClassDeclaration / ClassExpression
var visitClass = referencer.prototype.visitClass;
referencer.prototype.visitClass = function(node) {
var classBody = node.body.body;
for (var a = 0; a < classBody.length; a++) {
if (classBody[a].type === "ClassProperty") {
createScopeVariable.call(this, classBody[a], classBody[a].key);
}
}

visitDecorators.call(this, node);
var typeParamScope;
if (node.typeParameters) {
Expand Down

0 comments on commit 254e6ea

Please sign in to comment.