Create a variable for class properties in scope instead of deleting the key (babel/babel-eslint#336)

This commit is contained in:
Henry Zhu 2016-07-08 14:23:04 -04:00
parent 66a4cf578f
commit 9ee5e6e59c
2 changed files with 7 additions and 5 deletions

View File

@ -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;

View File

@ -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) {