check valid function/class token when parsing export default before converting to a declaration - fixes #2145
This commit is contained in:
@@ -648,9 +648,10 @@ pp.parseExport = function (node) {
|
||||
}
|
||||
this.parseExportFrom(node, true);
|
||||
} else if (this.eat(tt._default)) { // export default ...
|
||||
let possibleDeclaration = this.match(tt._function) || this.match(tt._class);
|
||||
let expr = this.parseMaybeAssign();
|
||||
let needsSemi = true;
|
||||
if (expr.type === "FunctionExpression" || expr.type === "ClassExpression") {
|
||||
if (possibleDeclaration) {
|
||||
needsSemi = false;
|
||||
if (expr.id) {
|
||||
expr.type = expr.type === "FunctionExpression" ? "FunctionDeclaration" : "ClassDeclaration";
|
||||
|
||||
Reference in New Issue
Block a user