fix no RHS in class properties causing undefined to be used instead of a noop - fixes #1396
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (descriptor.initializer) {
|
||||
if (descriptor.initializer !== undefined) {
|
||||
initializers[key] = descriptor;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -26,9 +26,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
descriptor.value = descriptor.initializer.call(target);
|
||||
|
||||
Object.defineProperty(target, key, descriptor);
|
||||
if (descriptor.initializer) {
|
||||
descriptor.value = descriptor.initializer.call(target);
|
||||
Object.defineProperty(target, key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
for (var _key in _descriptor) descriptor[_key] = _descriptor[_key];
|
||||
|
||||
// initialize it
|
||||
if (!descriptor.initializer) return;
|
||||
descriptor.value = descriptor.initializer.call(target);
|
||||
|
||||
Object.defineProperty(target, key, descriptor);
|
||||
|
||||
@@ -550,8 +550,12 @@ class ClassTransformer {
|
||||
|
||||
if (node.decorators) {
|
||||
var body = [];
|
||||
if (node.value) body.push(t.returnStatement(node.value));
|
||||
node.value = t.functionExpression(null, [], t.blockStatement(body));
|
||||
if (node.value) {
|
||||
body.push(t.returnStatement(node.value));
|
||||
node.value = t.functionExpression(null, [], t.blockStatement(body));
|
||||
} else {
|
||||
node.value = t.literal(null);
|
||||
}
|
||||
this.pushToMap(node, true, "initializer");
|
||||
|
||||
var initializers;
|
||||
@@ -575,7 +579,7 @@ class ClassTransformer {
|
||||
])
|
||||
));
|
||||
} else {
|
||||
node.value = node.value || t.identifier("undefined");
|
||||
if (!node.value && !node.decorators) return;
|
||||
|
||||
if (node.static) {
|
||||
// can just be added to the static map
|
||||
|
||||
Reference in New Issue
Block a user