diff --git a/src/printer.js b/src/printer.js index 705bb5359..2e99a8beb 100644 --- a/src/printer.js +++ b/src/printer.js @@ -2204,7 +2204,8 @@ function printFunctionParams(path, print, options) { // b, // c // }) {} - if (fun.params.length === 1 && + if (fun.params && + fun.params.length === 1 && !fun.params[0].comments && (fun.params[0].type === "ObjectPattern" || fun.params[0].type === "FunctionTypeParam" && diff --git a/tests/flow_object_comment/__snapshots__/jsfmt.spec.js.snap b/tests/flow_object_comment/__snapshots__/jsfmt.spec.js.snap index 1314cca0a..870d6ba15 100644 --- a/tests/flow_object_comment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow_object_comment/__snapshots__/jsfmt.spec.js.snap @@ -13,16 +13,14 @@ exports[`flow_object_comment.js 1`] = ` }, ) => {} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -export default ( - { - foo, - bar - }: { - // comment - foo?: Object, - // comment 2 - bar?: Object - } -) => {}; +export default ({ + foo, + bar +}: { + // comment + foo?: Object, + // comment 2 + bar?: Object +}) => {}; " `;