{"action":"created","comment":{"url":"https://api.github.com/repos/prettier/prettier/pulls/comments/226752324","pull_request_review_id":166656530,"id":226752324,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjc1MjMyNA==","diff_hunk":"@@ -2802,14 +2812,27 @@ function printPathNoParens(path, options, print, args) {\n \n       return group(concat(parts));\n     }\n-    case \"TypeCastExpression\":\n+    case \"TypeCastExpression\": {\n+      const value = path.getValue();\n+      // Flow supports a comment syntax for specifying type annotations: https://flow.org/en/docs/types/comments/.\n+      // Unfortunately, its parser doesn't differentiate between comment annotations and regular\n+      // annotations when producing an AST. So to preserve parentheses around type casts that use\n+      // the comment syntax, we need to hackily read the source itself to see if the code contains\n+      // a type annotation comment.\n+      const commentSyntax =\n+        value &&\n+        value.typeAnnotation &&\n+        value.typeAnnotation.range &&\n+        options.originalText.substr(value.typeAnnotation.range[0], 3) === \"/*:\";","path":"src/language-js/printer-estree.js","position":42,"original_position":42,"commit_id":"aee327cd04e13f3d990ba144d81e14149a0115c9","original_commit_id":"aee327cd04e13f3d990ba144d81e14149a0115c9","user":{"login":"j-f1","id":25517624,"node_id":"MDQ6VXNlcjI1NTE3NjI0","avatar_url":"https://avatars2.githubusercontent.com/u/25517624?v=4","gravatar_id":"","url":"https://api.github.com/users/j-f1","html_url":"https://github.com/j-f1","followers_url":"https://api.github.com/users/j-f1/followers","following_url":"https://api.github.com/users/j-f1/following{/other_user}","gists_url":"https://api.github.com/users/j-f1/gists{/gist_id}","starred_url":"https://api.github.com/users/j-f1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/j-f1/subscriptions","organizations_url":"https://api.github.com/users/j-f1/orgs","repos_url":"https://api.github.com/users/j-f1/repos","events_url":"https://api.github.com/users/j-f1/events{/privacy}","received_events_url":"https://api.github.com/users/j-f1/received_events","type":"User","site_admin":false},"body":"Similar question to the one in `flow-comments.js` — should this be checking against the regex `/^/\\*\\s*:/`?","created_at":"2018-10-19T19:07:06Z","updated_at":"2018-10-19T19:08:05Z","html_url":"https://github.com/prettier/prettier/pull/5280#discussion_r226752324","pull_request_url":"https://api.github.com/repos/prettier/prettier/pulls/5280","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/prettier/prettier/pulls/comments/226752324"},"html":{"href":"https://github.com/prettier/prettier/pull/5280#discussion_r226752324"},"pull_request":{"href":"https://api.github.com/repos/prettier/prettier/pulls/5280"}}},"pull_request":{"url":"https://api.github.com/repos/prettier/prettier/pulls/5280","id":224182692,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI0MTgyNjky","html_url":"https://github.com/prettier/prettier/pull/5280","diff_url":"https://github.com/prettier/prettier/pull/5280.diff","patch_url":"https://github.com/prettier/prettier/pull/5280.patch","issue_url":"https://api.github.com/repos/prettier/prettier/issues/5280","number":5280,"state":"open","locked":false,"title":"Add support for flow typecast comments","user":{"login":"swac","id":170313,"node_id":"MDQ6VXNlcjE3MDMxMw==","avatar_url":"https://avatars0.githubusercontent.com/u/170313?v=4","gravatar_id":"","url":"https://api.github.com/users/swac","html_url":"https://github.com/swac","followers_url":"https://api.github.com/users/swac/followers","following_url":"https://api.github.com/users/swac/following{/other_user}","gists_url":"https://api.github.com/users/swac/gists{/gist_id}","starred_url":"https://api.github.com/users/swac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swac/subscriptions","organizations_url":"https://api.github.com/users/swac/orgs","repos_url":"https://api.github.com/users/swac/repos","events_url":"https://api.github.com/users/swac/events{/privacy}","received_events_url":"https://api.github.com/users/swac/received_events","type":"User","site_admin":false},"body":"<!-- Please provide a brief summary of your changes: -->\r\n\r\nThis attempts to fix the bug described in #719. Previously, Prettier was removing parentheses in expressions like: \r\n\r\n```\r\nnew (window.Request /*: Class<Request> */)(\"\")\r\n```\r\n\r\nturning them into:\r\n\r\n```\r\nnew window.Request /*: Class<Request> */(\"\")\r\n```\r\n\r\nwhich no longer satisfies Flow's syntax. With this change, we detect these typecast expressions and attempt to keep the parentheses intact in such cases.\r\n\r\nThis is my first time contributing to Prettier, so I'm probably making some egregious mistakes!\r\n\r\n<!-- Please ensure you’ve done all of these things (if applicable). -->\r\n<!-- You can replace the `[ ]` with `[x]` to mark each task as done. -->\r\n\r\n- [x] I’ve added tests to confirm my change works.\r\n- [x] (If changing the API or CLI) I’ve documented the changes I’ve made (in the `docs/` directory)\r\n- [x] I’ve read the [contributing guidelines](https://github.com/prettier/prettier/blob/master/CONTRIBUTING.md).\r\n","created_at":"2018-10-19T06:25:33Z","updated_at":"2018-10-19T19:08:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"16ab044a25ab2349cda1121c1fa3b077cf937098","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/prettier/prettier/pulls/5280/commits","review_comments_url":"https://api.github.com/repos/prettier/prettier/pulls/5280/comments","review_comment_url":"https://api.github.com/repos/prettier/prettier/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prettier/prettier/issues/5280/comments","statuses_url":"https://api.github.com/repos/prettier/prettier/statuses/aee327cd04e13f3d990ba144d81e14149a0115c9","head":{"label":"swac:flowcomments","ref":"flowcomments","sha":"aee327cd04e13f3d990ba144d81e14149a0115c9","user":{"login":"swac","id":170313,"node_id":"MDQ6VXNlcjE3MDMxMw==","avatar_url":"https://avatars0.githubusercontent.com/u/170313?v=4","gravatar_id":"","url":"https://api.github.com/users/swac","html_url":"https://github.com/swac","followers_url":"https://api.github.com/users/swac/followers","following_url":"https://api.github.com/users/swac/following{/other_user}","gists_url":"https://api.github.com/users/swac/gists{/gist_id}","starred_url":"https://api.github.com/users/swac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swac/subscriptions","organizations_url":"https://api.github.com/users/swac/orgs","repos_url":"https://api.github.com/users/swac/repos","events_url":"https://api.github.com/users/swac/events{/privacy}","received_events_url":"https://api.github.com/users/swac/received_events","type":"User","site_admin":false},"repo":{"id":152890758,"node_id":"MDEwOlJlcG9zaXRvcnkxNTI4OTA3NTg=","name":"prettier","full_name":"swac/prettier","private":false,"owner":{"login":"swac","id":170313,"node_id":"MDQ6VXNlcjE3MDMxMw==","avatar_url":"https://avatars0.githubusercontent.com/u/170313?v=4","gravatar_id":"","url":"https://api.github.com/users/swac","html_url":"https://github.com/swac","followers_url":"https://api.github.com/users/swac/followers","following_url":"https://api.github.com/users/swac/following{/other_user}","gists_url":"https://api.github.com/users/swac/gists{/gist_id}","starred_url":"https://api.github.com/users/swac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swac/subscriptions","organizations_url":"https://api.github.com/users/swac/orgs","repos_url":"https://api.github.com/users/swac/repos","events_url":"https://api.github.com/users/swac/events{/privacy}","received_events_url":"https://api.github.com/users/swac/received_events","type":"User","site_admin":false},"html_url":"https://github.com/swac/prettier","description":"Prettier is an opinionated code formatter.","fork":true,"url":"https://api.github.com/repos/swac/prettier","forks_url":"https://api.github.com/repos/swac/prettier/forks","keys_url":"https://api.github.com/repos/swac/prettier/keys{/key_id}","collaborators_url":"https://api.github.com/repos/swac/prettier/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/swac/prettier/teams","hooks_url":"https://api.github.com/repos/swac/prettier/hooks","issue_events_url":"https://api.github.com/repos/swac/prettier/issues/events{/number}","events_url":"https://api.github.com/repos/swac/prettier/events","assignees_url":"https://api.github.com/repos/swac/prettier/assignees{/user}","branches_url":"https://api.github.com/repos/swac/prettier/branches{/branch}","tags_url":"https://api.github.com/repos/swac/prettier/tags","blobs_url":"https://api.github.com/repos/swac/prettier/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/swac/prettier/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/swac/prettier/git/refs{/sha}","trees_url":"https://api.github.com/repos/swac/prettier/git/trees{/sha}","statuses_url":"https://api.github.com/repos/swac/prettier/statuses/{sha}","languages_url":"https://api.github.com/repos/swac/prettier/languages","stargazers_url":"https://api.github.com/repos/swac/prettier/stargazers","contributors_url":"https://api.github.com/repos/swac/prettier/contributors","subscribers_url":"https://api.github.com/repos/swac/prettier/subscribers","subscription_url":"https://api.github.com/repos/swac/prettier/subscription","commits_url":"https://api.github.com/repos/swac/prettier/commits{/sha}","git_commits_url":"https://api.github.com/repos/swac/prettier/git/commits{/sha}","comments_url":"https://api.github.com/repos/swac/prettier/comments{/number}","issue_comment_url":"https://api.github.com/repos/swac/prettier/issues/comments{/number}","contents_url":"https://api.github.com/repos/swac/prettier/contents/{+path}","compare_url":"https://api.github.com/repos/swac/prettier/compare/{base}...{head}","merges_url":"https://api.github.com/repos/swac/prettier/merges","archive_url":"https://api.github.com/repos/swac/prettier/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/swac/prettier/downloads","issues_url":"https://api.github.com/repos/swac/prettier/issues{/number}","pulls_url":"https://api.github.com/repos/swac/prettier/pulls{/number}","milestones_url":"https://api.github.com/repos/swac/prettier/milestones{/number}","notifications_url":"https://api.github.com/repos/swac/prettier/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/swac/prettier/labels{/name}","releases_url":"https://api.github.com/repos/swac/prettier/releases{/id}","deployments_url":"https://api.github.com/repos/swac/prettier/deployments","created_at":"2018-10-13T16:21:12Z","updated_at":"2018-10-13T16:21:19Z","pushed_at":"2018-10-19T15:11:16Z","git_url":"git://github.com/swac/prettier.git","ssh_url":"git@github.com:swac/prettier.git","clone_url":"https://github.com/swac/prettier.git","svn_url":"https://github.com/swac/prettier","homepage":"https://prettier.io","size":25136,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prettier:master","ref":"master","sha":"62e4654e60561acb7b4cba8b35582f85e63a6acd","user":{"login":"prettier","id":25822731,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1ODIyNzMx","avatar_url":"https://avatars2.githubusercontent.com/u/25822731?v=4","gravatar_id":"","url":"https://api.github.com/users/prettier","html_url":"https://github.com/prettier","followers_url":"https://api.github.com/users/prettier/followers","following_url":"https://api.github.com/users/prettier/following{/other_user}","gists_url":"https://api.github.com/users/prettier/gists{/gist_id}","starred_url":"https://api.github.com/users/prettier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prettier/subscriptions","organizations_url":"https://api.github.com/users/prettier/orgs","repos_url":"https://api.github.com/users/prettier/repos","events_url":"https://api.github.com/users/prettier/events{/privacy}","received_events_url":"https://api.github.com/users/prettier/received_events","type":"Organization","site_admin":false},"repo":{"id":75104123,"node_id":"MDEwOlJlcG9zaXRvcnk3NTEwNDEyMw==","name":"prettier","full_name":"prettier/prettier","private":false,"owner":{"login":"prettier","id":25822731,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1ODIyNzMx","avatar_url":"https://avatars2.githubusercontent.com/u/25822731?v=4","gravatar_id":"","url":"https://api.github.com/users/prettier","html_url":"https://github.com/prettier","followers_url":"https://api.github.com/users/prettier/followers","following_url":"https://api.github.com/users/prettier/following{/other_user}","gists_url":"https://api.github.com/users/prettier/gists{/gist_id}","starred_url":"https://api.github.com/users/prettier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prettier/subscriptions","organizations_url":"https://api.github.com/users/prettier/orgs","repos_url":"https://api.github.com/users/prettier/repos","events_url":"https://api.github.com/users/prettier/events{/privacy}","received_events_url":"https://api.github.com/users/prettier/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/prettier/prettier","description":"Prettier is an opinionated code formatter.","fork":false,"url":"https://api.github.com/repos/prettier/prettier","forks_url":"https://api.github.com/repos/prettier/prettier/forks","keys_url":"https://api.github.com/repos/prettier/prettier/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prettier/prettier/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prettier/prettier/teams","hooks_url":"https://api.github.com/repos/prettier/prettier/hooks","issue_events_url":"https://api.github.com/repos/prettier/prettier/issues/events{/number}","events_url":"https://api.github.com/repos/prettier/prettier/events","assignees_url":"https://api.github.com/repos/prettier/prettier/assignees{/user}","branches_url":"https://api.github.com/repos/prettier/prettier/branches{/branch}","tags_url":"https://api.github.com/repos/prettier/prettier/tags","blobs_url":"https://api.github.com/repos/prettier/prettier/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prettier/prettier/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prettier/prettier/git/refs{/sha}","trees_url":"https://api.github.com/repos/prettier/prettier/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prettier/prettier/statuses/{sha}","languages_url":"https://api.github.com/repos/prettier/prettier/languages","stargazers_url":"https://api.github.com/repos/prettier/prettier/stargazers","contributors_url":"https://api.github.com/repos/prettier/prettier/contributors","subscribers_url":"https://api.github.com/repos/prettier/prettier/subscribers","subscription_url":"https://api.github.com/repos/prettier/prettier/subscription","commits_url":"https://api.github.com/repos/prettier/prettier/commits{/sha}","git_commits_url":"https://api.github.com/repos/prettier/prettier/git/commits{/sha}","comments_url":"https://api.github.com/repos/prettier/prettier/comments{/number}","issue_comment_url":"https://api.github.com/repos/prettier/prettier/issues/comments{/number}","contents_url":"https://api.github.com/repos/prettier/prettier/contents/{+path}","compare_url":"https://api.github.com/repos/prettier/prettier/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prettier/prettier/merges","archive_url":"https://api.github.com/repos/prettier/prettier/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prettier/prettier/downloads","issues_url":"https://api.github.com/repos/prettier/prettier/issues{/number}","pulls_url":"https://api.github.com/repos/prettier/prettier/pulls{/number}","milestones_url":"https://api.github.com/repos/prettier/prettier/milestones{/number}","notifications_url":"https://api.github.com/repos/prettier/prettier/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prettier/prettier/labels{/name}","releases_url":"https://api.github.com/repos/prettier/prettier/releases{/id}","deployments_url":"https://api.github.com/repos/prettier/prettier/deployments","created_at":"2016-11-29T17:13:37Z","updated_at":"2018-10-19T17:39:53Z","pushed_at":"2018-10-19T16:56:22Z","git_url":"git://github.com/prettier/prettier.git","ssh_url":"git@github.com:prettier/prettier.git","clone_url":"https://github.com/prettier/prettier.git","svn_url":"https://github.com/prettier/prettier","homepage":"https://prettier.io","size":25888,"stargazers_count":28007,"watchers_count":28007,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1397,"mirror_url":null,"archived":false,"open_issues_count":422,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1397,"open_issues":422,"watchers":28007,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prettier/prettier/pulls/5280"},"html":{"href":"https://github.com/prettier/prettier/pull/5280"},"issue":{"href":"https://api.github.com/repos/prettier/prettier/issues/5280"},"comments":{"href":"https://api.github.com/repos/prettier/prettier/issues/5280/comments"},"review_comments":{"href":"https://api.github.com/repos/prettier/prettier/pulls/5280/comments"},"review_comment":{"href":"https://api.github.com/repos/prettier/prettier/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prettier/prettier/pulls/5280/commits"},"statuses":{"href":"https://api.github.com/repos/prettier/prettier/statuses/aee327cd04e13f3d990ba144d81e14149a0115c9"}},"author_association":"NONE"}}
{"actor":{"display_login":"j-f1"}}