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

Commit 254e6ea

Browse files
authored
Create a variable for class properties in scope instead of deleting the key (#336)
1 parent 2d72002 commit 254e6ea

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

babylon-to-espree/toAST.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,6 @@ var astTransformVisitor = {
206206
}
207207
}
208208

209-
// remove class property keys (or patch in escope)
210-
if (path.isClassProperty()) {
211-
delete node.key;
212-
}
213-
214209
// async function as generator
215210
if (path.isFunction()) {
216211
if (node.async) node.generator = true;

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,13 @@ function monkeypatch() {
229229
// visit decorators that are in: ClassDeclaration / ClassExpression
230230
var visitClass = referencer.prototype.visitClass;
231231
referencer.prototype.visitClass = function(node) {
232+
var classBody = node.body.body;
233+
for (var a = 0; a < classBody.length; a++) {
234+
if (classBody[a].type === "ClassProperty") {
235+
createScopeVariable.call(this, classBody[a], classBody[a].key);
236+
}
237+
}
238+
232239
visitDecorators.call(this, node);
233240
var typeParamScope;
234241
if (node.typeParameters) {

0 commit comments

Comments
 (0)