Unrestrict flow union comments check (#1040)

I was being very careful by checking all the surrounding types but it actually turns out we want this behavior all the time.

Fixes #931
master
Christopher Chedeau 2017-03-20 09:33:42 -07:00 committed by James Long
parent a9185cb30e
commit 82d6e0b4ab
3 changed files with 51 additions and 5 deletions

View File

@ -580,11 +580,7 @@ function handleUnionTypeComments(
) {
if (
enclosingNode &&
enclosingNode.type === "UnionTypeAnnotation" &&
precedingNode &&
precedingNode.type === "ObjectTypeAnnotation" &&
followingNode &&
followingNode.type === "ObjectTypeAnnotation"
enclosingNode.type === "UnionTypeAnnotation"
) {
addTrailingComment(precedingNode, comment);
return true;

View File

@ -352,6 +352,16 @@ exports[`flow_union.js 1`] = `
| {type: \\"Failed\\", error: E, errorMsg: EM}
// Uploading to aws3 and CreatePostMutation succeeded
| {type: \\"Success\\", data: D};
type UploadState<E, EM, D>
// The upload hasnt begun yet
= A
// The upload timed out
| B
// Failed somewhere on the line
| C
// Uploading to aws3 and CreatePostMutation succeeded
| D;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type UploadState<E, EM, D> =
// The upload hasnt begun yet
@ -362,6 +372,16 @@ type UploadState<E, EM, D> =
| { type: \\"Failed\\", error: E, errorMsg: EM }
// Uploading to aws3 and CreatePostMutation succeeded
| { type: \\"Success\\", data: D };
type UploadState<E, EM, D> =
// The upload hasnt begun yet
| A
// The upload timed out
| B
// Failed somewhere on the line
| C
// Uploading to aws3 and CreatePostMutation succeeded
| D;
"
`;
@ -375,6 +395,16 @@ exports[`flow_union.js 2`] = `
| {type: \\"Failed\\", error: E, errorMsg: EM}
// Uploading to aws3 and CreatePostMutation succeeded
| {type: \\"Success\\", data: D};
type UploadState<E, EM, D>
// The upload hasnt begun yet
= A
// The upload timed out
| B
// Failed somewhere on the line
| C
// Uploading to aws3 and CreatePostMutation succeeded
| D;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type UploadState<E, EM, D> =
// The upload hasnt begun yet
@ -385,6 +415,16 @@ type UploadState<E, EM, D> =
| { type: \\"Failed\\", error: E, errorMsg: EM }
// Uploading to aws3 and CreatePostMutation succeeded
| { type: \\"Success\\", data: D };
type UploadState<E, EM, D> =
// The upload hasnt begun yet
| A
// The upload timed out
| B
// Failed somewhere on the line
| C
// Uploading to aws3 and CreatePostMutation succeeded
| D;
"
`;

View File

@ -7,3 +7,13 @@ type UploadState<E, EM, D>
| {type: "Failed", error: E, errorMsg: EM}
// Uploading to aws3 and CreatePostMutation succeeded
| {type: "Success", data: D};
type UploadState<E, EM, D>
// The upload hasnt begun yet
= A
// The upload timed out
| B
// Failed somewhere on the line
| C
// Uploading to aws3 and CreatePostMutation succeeded
| D;