Don't require a semicolon after 'export default [function|class] ...'
Issue #225
This commit is contained in:
parent
1fc1d32e1f
commit
44c0231c09
@ -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 ...
|
||||
|
||||
@ -15596,3 +15596,32 @@ test("new.target", {
|
||||
}, {ecmaVersion: 6});
|
||||
|
||||
testFail("new.prop", "The only valid meta property for new is new.target (1:4)", {ecmaVersion: 6});
|
||||
|
||||
test("export default function () {} false", {
|
||||
body: [
|
||||
{
|
||||
declaration: {
|
||||
id: null,
|
||||
generator: false,
|
||||
expression: false,
|
||||
params: [],
|
||||
body: {
|
||||
body: [],
|
||||
type: "BlockStatement"
|
||||
},
|
||||
type: "FunctionExpression"
|
||||
},
|
||||
type: "ExportDefaultDeclaration"
|
||||
},
|
||||
{
|
||||
expression: {
|
||||
value: false,
|
||||
raw: "false",
|
||||
type: "Literal"
|
||||
},
|
||||
type: "ExpressionStatement"
|
||||
}
|
||||
],
|
||||
sourceType: "module",
|
||||
type: "Program"
|
||||
}, {ecmaVersion: 6, sourceType: "module"})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user