make export default anoynmous class/function statements - fixes #2205
This commit is contained in:
@@ -121,7 +121,15 @@ export function YieldExpression(node, parent) {
|
||||
}
|
||||
|
||||
export function ClassExpression(node, parent) {
|
||||
return t.isExpressionStatement(parent);
|
||||
// (class {});
|
||||
if (t.isExpressionStatement(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// export default (class () {});
|
||||
if (t.isExportDeclaration(parent)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export function UnaryLike(node, parent) {
|
||||
@@ -129,11 +137,16 @@ export function UnaryLike(node, parent) {
|
||||
}
|
||||
|
||||
export function FunctionExpression(node, parent) {
|
||||
// function () {};
|
||||
// (function () {});
|
||||
if (t.isExpressionStatement(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// export default (function () {});
|
||||
if (t.isExportDeclaration(parent)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// (function test() {}).name;
|
||||
if (t.isMemberExpression(parent) && parent.object === node) {
|
||||
return true;
|
||||
|
||||
@@ -673,10 +673,8 @@ pp.parseExport = function (node) {
|
||||
let needsSemi = false;
|
||||
if (this.eat(tt._function)) {
|
||||
expr = this.parseFunction(expr, true, false, false, true);
|
||||
if (!expr.id) expr.type = "FunctionExpression";
|
||||
} else if (this.match(tt._class)) {
|
||||
expr = this.parseClass(expr, true, true);
|
||||
if (!expr.id) expr.type = "ClassExpression";
|
||||
} else {
|
||||
needsSemi = true;
|
||||
expr = this.parseMaybeAssign();
|
||||
|
||||
Reference in New Issue
Block a user