Fix unstable arrow comments (#2262)

It outputted which is completely wrong

```js
<FlatList
  renderItem={info => <span>{info.item.widget.missingProp // $FlowExpectedError - bad widgetCount type 6, should be Object
    }</span>}
/>;
```
This commit is contained in:
Christopher Chedeau authored and Lucas Azzola committed 2017-06-25 12:30:09 +10:00
1 parent 438f5887e2
commit 9a55f5b2d6
4 files changed
+29 -3

No files matched your search

+5 -2
View File
@@ -2963,7 +2963,10 @@ function printFunctionParams(path, print, options, expandArg, printTypeParams) {
// } b,
// }) ) => {
// })
if (expandArg) {
if (
expandArg &&
!(fun[paramsField] && fun[paramsField].some(n => n.comments))
) {
return group(
concat([
docUtils.removeLines(typeParams),
@@ -3047,7 +3050,7 @@ function canPrintParamsWithoutParens(node) {
!node.rest &&
node.params[0].type === "Identifier" &&
!node.params[0].typeAnnotation &&
!util.hasBlockComments(node.params[0]) &&
!node.params[0].comments &&
!node.params[0].optional &&
!node.predicate &&
!node.returnType
@@ -269,6 +269,13 @@ export const bem = block =>
element ? \`__\${css(element)}\` : "",
modifier ? \`--\${css(modifier)}\` : ""
].join("");
<FlatList
renderItem={(
info, // $FlowExpectedError - bad widgetCount type 6, should be Object
) => <span>{info.item.widget.missingProp}</span>}
data={data}
/>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
* Curried function that ends with a BEM CSS Selector
@@ -294,6 +301,13 @@ export const bem = block =>
modifier ? \`--\${css(modifier)}\` : ""
].join("");
<FlatList
renderItem={(
info // $FlowExpectedError - bad widgetCount type 6, should be Object
) => <span>{info.item.widget.missingProp}</span>}
data={data}
/>;
`;
exports[`currying.js 1`] = `
+7
View File
@@ -21,3 +21,10 @@ export const bem = block =>
element ? `__${css(element)}` : "",
modifier ? `--${css(modifier)}` : ""
].join("");
<FlatList
renderItem={(
info, // $FlowExpectedError - bad widgetCount type 6, should be Object
) => <span>{info.item.widget.missingProp}</span>}
data={data}
/>
@@ -243,7 +243,9 @@ function a(/* comment */) {} // comment
function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment
call((/*object*/ row) => {});
KEYPAD_NUMBERS.map(num => <div />); // Buttons 0-9
KEYPAD_NUMBERS.map((
num // Buttons 0-9
) => <div />);
`;