better ClassDeclarations in expression contexts
This commit is contained in:
@@ -9,10 +9,15 @@ exports.ClassDeclaration = function (node, parent, file, scope) {
|
||||
}
|
||||
|
||||
var newNode = new Class(node, file, scope, closure).run();
|
||||
if (closure || t.isFunctionExpression(newNode)) {
|
||||
return t.variableDeclaration("let", [
|
||||
t.variableDeclarator(node.id, newNode)
|
||||
]);
|
||||
if (closure) {
|
||||
// declaration in an expression context...
|
||||
// export default class Foo {}
|
||||
scope.push({
|
||||
kind: "var",
|
||||
key: node.id.key,
|
||||
id: node.id
|
||||
});
|
||||
return t.assignmentExpression("=", node.id, newNode);
|
||||
} else {
|
||||
return newNode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user