diff --git a/src/comments.js b/src/comments.js index 101044ea..efcb72d9 100644 --- a/src/comments.js +++ b/src/comments.js @@ -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; diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap index 5f9b2f9e..6c09b620 100644 --- a/tests/comments/__snapshots__/jsfmt.spec.js.snap +++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap @@ -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 + // 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 = // The upload hasnt begun yet @@ -362,6 +372,16 @@ type UploadState = | { type: \\"Failed\\", error: E, errorMsg: EM } // Uploading to aws3 and CreatePostMutation succeeded | { type: \\"Success\\", data: D }; + +type UploadState = + // 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 + // 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 = // The upload hasnt begun yet @@ -385,6 +415,16 @@ type UploadState = | { type: \\"Failed\\", error: E, errorMsg: EM } // Uploading to aws3 and CreatePostMutation succeeded | { type: \\"Success\\", data: D }; + +type UploadState = + // The upload hasnt begun yet + | A + // The upload timed out + | B + // Failed somewhere on the line + | C + // Uploading to aws3 and CreatePostMutation succeeded + | D; " `; diff --git a/tests/comments/flow_union.js b/tests/comments/flow_union.js index d76a0481..9d67d295 100644 --- a/tests/comments/flow_union.js +++ b/tests/comments/flow_union.js @@ -7,3 +7,13 @@ type UploadState | {type: "Failed", error: E, errorMsg: EM} // Uploading to aws3 and CreatePostMutation succeeded | {type: "Success", data: D}; + +type UploadState + // The upload hasnt begun yet + = A + // The upload timed out + | B + // Failed somewhere on the line + | C + // Uploading to aws3 and CreatePostMutation succeeded + | D;