{"action":"opened","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/4902","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/4902/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/4902/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/4902/events","html_url":"https://github.com/facebook/flow/issues/4902","id":258320963,"number":4902,"title":"Flow is not type checking this union correctly","user":{"login":"pfftdammitchris","id":20717348,"avatar_url":"https://avatars2.githubusercontent.com/u/20717348?v=4","gravatar_id":"","url":"https://api.github.com/users/pfftdammitchris","html_url":"https://github.com/pfftdammitchris","followers_url":"https://api.github.com/users/pfftdammitchris/followers","following_url":"https://api.github.com/users/pfftdammitchris/following{/other_user}","gists_url":"https://api.github.com/users/pfftdammitchris/gists{/gist_id}","starred_url":"https://api.github.com/users/pfftdammitchris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfftdammitchris/subscriptions","organizations_url":"https://api.github.com/users/pfftdammitchris/orgs","repos_url":"https://api.github.com/users/pfftdammitchris/repos","events_url":"https://api.github.com/users/pfftdammitchris/events{/privacy}","received_events_url":"https://api.github.com/users/pfftdammitchris/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-09-17T18:03:13Z","updated_at":"2017-09-17T18:03:13Z","closed_at":null,"author_association":"NONE","body":"Hello all. I recently developed an excitement to type check my whole app after realizing how fun it is and now I am stuck with a problem of correctly type checking a redux action creator (dispatching). Also, I am a tiny bit over a year into programming now and will soon become a regular contributor to the flow community at github--which means flow will be my first community I will contribute to (regularly as well). Yay! It doesn't sound exciting to you readers but its exciting to me. I am growing a huge desire to dig really deep into facebook's flow type checker and help you all out soon in answering questions and fixing bugs as soon as I have dug in deep into flow's type system soon.\r\n\r\nAnyways,\r\nFollowing the guide at [here](https://flow.org/en/docs/react/redux/) my typings are very similar. However, the error comes up in my IDE (atom) that the \"object literal in incompatible with union: Actions | ThunkAction | PromiseAction | array type\", but the types that I have defined look very exactly matched. \r\n\r\n**Target code:**\r\n```\r\nexport const getPosts = (collectionName: string): ThunkAction => {\r\n  return (dispatch) => {\r\n    dispatch({ type: JSREACTDAILY_FETCHING });\r\n    const collection = db.collection(collectionName);\r\n    client.login()\r\n      .then(() =>\r\n        collection.find({})\r\n          .then((data: any) => dispatch({ type: JSREACTDAILY_FETCH_SUCCESS, posts: 'data' }))\r\n          .catch((err: any) => dispatch({ type: JSREACTDAILY_FETCH_FAIL, posts: err }))\r\n      ).catch(err => { throw err; });\r\n  };\r\n};\r\n```\r\n\r\nTypings:\r\n```\r\nexport type FetchingPosts = {\r\n  +type: 'JSREACTDAILY_FETCHING',\r\n}\r\nexport type FetchPostsSuccess = {\r\n  +type: 'JSREACTDAILY_FETCH_SUCCESS',\r\n  +posts: any,\r\n}\r\nexport type FetchPostsFailed = {\r\n  +type: 'JSREACTDAILY_FETCH_FAIL',\r\n  +posts: any,\r\n}\r\n\r\nexport type Actions =\r\n  | FetchingPosts\r\n  | FetchPostsSuccess\r\n  | FetchPostsFailed;\r\n\r\nexport type ThunkAction = (dispatch: Dispatch) => any;\r\nexport type PromiseAction = Promise<Actions>;\r\nexport type Dispatch = (action: Actions | ThunkAction | PromiseAction | Array<Actions>) => any;\r\n```\r\n\r\nIn the IDE, this is what it looks like in the target code:\r\n![coffee](https://user-images.githubusercontent.com/20717348/30523511-85f3f3ee-9b97-11e7-8726-ffc4458efc3b.png)\r\n\r\nHere is what it looks like in the typings:\r\n![5555](https://user-images.githubusercontent.com/20717348/30523534-cb90bcac-9b97-11e7-9cda-95dca15d54f4.png)\r\n\r\n\r\n"}}
{"actor":{"display_login":"pfftdammitchris"}}