From 332babe77dd3dd742833fac3166908cbd35b07ba Mon Sep 17 00:00:00 2001 From: Dan Harper Date: Wed, 15 Mar 2017 16:38:13 +0000 Subject: [PATCH] Fix single optional arrow param printing (#1002) --- src/printer.js | 1 + tests/arrows/__snapshots__/jsfmt.spec.js.snap | 2 ++ tests/arrows/arrow_function_expression.js | 1 + 3 files changed, 4 insertions(+) diff --git a/src/printer.js b/src/printer.js index 9efe3087..d14e07ac 100644 --- a/src/printer.js +++ b/src/printer.js @@ -315,6 +315,7 @@ function genericPrintNoParens(path, options, print) { !n.params[0].typeAnnotation && !n.params[0].leadingComments && !n.params[0].trailingComments && + !n.params[0].optional && !n.predicate && !n.returnType ) { diff --git a/tests/arrows/__snapshots__/jsfmt.spec.js.snap b/tests/arrows/__snapshots__/jsfmt.spec.js.snap index 2d71164c..fa959434 100644 --- a/tests/arrows/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrows/__snapshots__/jsfmt.spec.js.snap @@ -30,6 +30,7 @@ x => ({}().b); (a => b)::c; a::(b => c); a = b => c; +a = (b?) => c; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (a => {}).length; typeof (() => {}); @@ -61,6 +62,7 @@ x => ({}().b); (a => b)::c; a::(b => c); a = b => c; +a = (b?) => c; " `; diff --git a/tests/arrows/arrow_function_expression.js b/tests/arrows/arrow_function_expression.js index 20f801c7..3435c417 100644 --- a/tests/arrows/arrow_function_expression.js +++ b/tests/arrows/arrow_function_expression.js @@ -27,3 +27,4 @@ x => ({}().b); (a => b)::c; a::(b => c); a = b => c; +a = (b?) => c;