add descriptor for all class properties - fixes #1235
This commit is contained in:
@@ -33,12 +33,14 @@ export function push(mutatorMap, node, kind, file) {
|
||||
throw file.errorWithNode(node, "Key conflict with sibling node");
|
||||
}
|
||||
|
||||
if (node.kind === "init") kind = "value";
|
||||
if (node.kind === "get") kind = "get";
|
||||
if (node.kind === "set") kind = "set";
|
||||
if (node.value) {
|
||||
if (node.kind === "init") kind = "value";
|
||||
if (node.kind === "get") kind = "get";
|
||||
if (node.kind === "set") kind = "set";
|
||||
|
||||
t.inheritsComments(node.value, node);
|
||||
map[kind] = node.value;
|
||||
t.inheritsComments(node.value, node);
|
||||
map[kind] = node.value;
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -517,8 +517,6 @@ class ClassTransformer {
|
||||
*/
|
||||
|
||||
pushProperty(node: { type: "ClassProperty" }) {
|
||||
if (!node.value && !node.decorators) return;
|
||||
|
||||
var key;
|
||||
|
||||
this.scope.traverse(node, collectPropertyReferencesVisitor, {
|
||||
@@ -545,16 +543,17 @@ class ClassTransformer {
|
||||
}, true));
|
||||
}
|
||||
} else {
|
||||
if (node.static) {
|
||||
// can just be added to the static map
|
||||
this.pushToMap(node, true);
|
||||
} else {
|
||||
if (!node.static && node.value) {
|
||||
// add this to the instancePropBody which will be added after the super call in a derived constructor
|
||||
// or at the start of a constructor for a non-derived constructor
|
||||
this.instancePropBody.push(t.expressionStatement(
|
||||
t.assignmentExpression("=", t.memberExpression(t.thisExpression(), node.key), node.value)
|
||||
));
|
||||
node.value = t.identifier("undefined");
|
||||
}
|
||||
|
||||
// can just be added to the static map
|
||||
this.pushToMap(node, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user