Fix #4774: `export default` followed by an object should always work, even if the object contains braces. `default` shouldn't suppress a newline, we should handle it in the grammar the same way returning an implicit object is handled (#4783)
This commit is contained in:
parent
bd824c73dd
commit
637fe305a6
|
@ -822,6 +822,10 @@
|
|||
function() {
|
||||
return new ExportDefaultDeclaration($3);
|
||||
}),
|
||||
o('EXPORT DEFAULT INDENT Object OUTDENT',
|
||||
function() {
|
||||
return new ExportDefaultDeclaration(new Value($4));
|
||||
}),
|
||||
o('EXPORT EXPORT_ALL FROM String',
|
||||
function() {
|
||||
return new ExportAllDeclaration(new Literal($2),
|
||||
|
|
|
@ -1685,6 +1685,6 @@
|
|||
INDENTABLE_CLOSERS = [')', '}', ']'];
|
||||
|
||||
// Tokens that, when appearing at the end of a line, suppress a following TERMINATOR/INDENT token
|
||||
UNFINISHED = ['\\', '.', '?.', '?::', 'UNARY', 'MATH', 'UNARY_MATH', '+', '-', '**', 'SHIFT', 'RELATION', 'COMPARE', '&', '^', '|', '&&', '||', 'BIN?', 'EXTENDS', 'DEFAULT'];
|
||||
UNFINISHED = ['\\', '.', '?.', '?::', 'UNARY', 'MATH', 'UNARY_MATH', '+', '-', '**', 'SHIFT', 'RELATION', 'COMPARE', '&', '^', '|', '&&', '||', 'BIN?', 'EXTENDS'];
|
||||
|
||||
}).call(this);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -439,6 +439,7 @@ grammar =
|
|||
o 'EXPORT Identifier = INDENT Expression OUTDENT', -> new ExportNamedDeclaration new Assign $2, $5, null,
|
||||
moduleDeclaration: 'export'
|
||||
o 'EXPORT DEFAULT Expression', -> new ExportDefaultDeclaration $3
|
||||
o 'EXPORT DEFAULT INDENT Object OUTDENT', -> new ExportDefaultDeclaration new Value $4
|
||||
o 'EXPORT EXPORT_ALL FROM String', -> new ExportAllDeclaration new Literal($2), $4
|
||||
o 'EXPORT { ExportSpecifierList OptComma } FROM String', -> new ExportNamedDeclaration new ExportSpecifierList($3), $7
|
||||
]
|
||||
|
|
|
@ -1354,4 +1354,4 @@ INDENTABLE_CLOSERS = [')', '}', ']']
|
|||
# Tokens that, when appearing at the end of a line, suppress a following TERMINATOR/INDENT token
|
||||
UNFINISHED = ['\\', '.', '?.', '?::', 'UNARY', 'MATH', 'UNARY_MATH', '+', '-',
|
||||
'**', 'SHIFT', 'RELATION', 'COMPARE', '&', '^', '|', '&&', '||',
|
||||
'BIN?', 'EXTENDS', 'DEFAULT']
|
||||
'BIN?', 'EXTENDS']
|
||||
|
|
|
@ -329,7 +329,7 @@ test "export default implicit object", ->
|
|||
test "export default multiline implicit object", ->
|
||||
eqJS """
|
||||
export default
|
||||
foo: 'bar',
|
||||
foo: 'bar'
|
||||
baz: 'qux'
|
||||
""",
|
||||
"""
|
||||
|
@ -338,6 +338,22 @@ test "export default multiline implicit object", ->
|
|||
baz: 'qux'
|
||||
};"""
|
||||
|
||||
test "export default multiline implicit object with internal braces", ->
|
||||
eqJS """
|
||||
export default
|
||||
foo: yes
|
||||
bar: {
|
||||
baz
|
||||
}
|
||||
quz: no
|
||||
""",
|
||||
"""
|
||||
export default {
|
||||
foo: true,
|
||||
bar: {baz},
|
||||
quz: false
|
||||
};"""
|
||||
|
||||
test "export default assignment expression", ->
|
||||
eqJS "export default foo = 'bar'",
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue