Don't require a semicolon after 'export default [function|class] ...'

Issue #225
This commit is contained in:
Marijn Haverbeke
2015-03-20 22:40:51 +01:00
parent 1fc1d32e1f
commit 44c0231c09
2 changed files with 33 additions and 4 deletions

View File

@@ -458,14 +458,14 @@ pp.parseExport = function(node) {
}
if (this.eat(tt._default)) { // export default ...
let expr = this.parseMaybeAssign()
if (expr.id) {
switch (expr.type) {
let needsSemi = false
if (expr.id) switch (expr.type) {
case "FunctionExpression": expr.type = "FunctionDeclaration"; break
case "ClassExpression": expr.type = "ClassDeclaration"; break
}
default: needsSemi = true
}
node.declaration = expr
this.semicolon()
if (needsSemi) this.semicolon()
return this.finishNode(node, "ExportDefaultDeclaration")
}
// export var|const|let|function|class ...