diff --git a/src/generation/generate.rs b/src/generation/generate.rs index 35e08eae..2b31076f 100644 --- a/src/generation/generate.rs +++ b/src/generation/generate.rs @@ -2581,7 +2581,7 @@ fn gen_fn_expr<'a>(node: &FnExpr<'a>, context: &mut Context<'a>) -> PrintItems { let items = gen_function_decl_or_expr( FunctionDeclOrExprNode { node: node.into(), - is_func_decl: false, + is_func_decl: node.parent().kind() == NodeKind::ExportDefaultDecl && node.ident.is_some(), ident: node.ident, declare: false, func: node.function, diff --git a/tests/specs/declarations/function/Function_SpaceBeforeParentheses_True.txt b/tests/specs/declarations/function/Function_SpaceBeforeParentheses_True.txt index f8a79734..6de068cc 100644 --- a/tests/specs/declarations/function/Function_SpaceBeforeParentheses_True.txt +++ b/tests/specs/declarations/function/Function_SpaceBeforeParentheses_True.txt @@ -3,10 +3,16 @@ function test() { } +export default function test() { +} + [expect] function test () { } +export default function test () { +} + == should format with a space before the parens even when multi-line == function test(param, otherParam, testing) { } diff --git a/tests/specs/expressions/FunctionExpression/FunctionExpression_SpaceBeforeParentheses_True.txt b/tests/specs/expressions/FunctionExpression/FunctionExpression_SpaceBeforeParentheses_True.txt index 2030b2e6..9081a0af 100644 --- a/tests/specs/expressions/FunctionExpression/FunctionExpression_SpaceBeforeParentheses_True.txt +++ b/tests/specs/expressions/FunctionExpression/FunctionExpression_SpaceBeforeParentheses_True.txt @@ -8,6 +8,11 @@ const w = function test(testing, thisOut){ const x = function*() {}; const y = function ident() {}; +export default function test() { +} +export default function() { +} + [expect] const t = function (p, u) {}; const u = function (p, u) {}; @@ -19,3 +24,8 @@ const w = function test ( }; const x = function* () {}; const y = function ident () {}; + +export default function test() { +} +export default function () { +}