{"action":"closed","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/5955","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/5955/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/5955/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/5955/events","html_url":"https://github.com/facebook/flow/issues/5955","id":305224462,"number":5955,"title":"Flow doesn't recognize when Array.filter() filters out specific types","user":{"login":"EvHaus","id":226640,"avatar_url":"https://avatars3.githubusercontent.com/u/226640?v=4","gravatar_id":"","url":"https://api.github.com/users/EvHaus","html_url":"https://github.com/EvHaus","followers_url":"https://api.github.com/users/EvHaus/followers","following_url":"https://api.github.com/users/EvHaus/following{/other_user}","gists_url":"https://api.github.com/users/EvHaus/gists{/gist_id}","starred_url":"https://api.github.com/users/EvHaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EvHaus/subscriptions","organizations_url":"https://api.github.com/users/EvHaus/orgs","repos_url":"https://api.github.com/users/EvHaus/repos","events_url":"https://api.github.com/users/EvHaus/events{/privacy}","received_events_url":"https://api.github.com/users/EvHaus/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-14T16:05:12Z","updated_at":"2018-03-14T16:06:52Z","closed_at":"2018-03-14T16:06:52Z","author_association":"NONE","body":"The following code:\r\n\r\n```\r\n/* @flow */\r\n\r\nconst arr: Array<?number> = [1, null, 2]\r\n\r\nconst cleanArr: Array<number> = arr.filter((a: ?number): boolean => a !== null);\r\n```\r\n\r\nReturns the following Flow errors:\r\n\r\n```\r\n5: const cleanArr: Array<number> = arr.filter((a: ?number): boolean => a !== null);\r\n                                   ^ Cannot assign `arr.filter(...)` to `cleanArr` because null or undefined [1] is incompatible with number [2] in array element.\r\nReferences:\r\n3: const arr: Array<?number> = [1, null, 2]\r\n                    ^ [1]\r\n5: const cleanArr: Array<number> = arr.filter((a: ?number): boolean => a !== null);\r\n                         ^ [2]\r\n```\r\n\r\nIn my case, I have an `arr` array that has `null` values, but I want a `cleanArr` array that strips those nulls out via a `filter` function. It seems that flow doesn't recognize that `null` values were removed and still warns me that `cleanArr` can contain `null` values when it certainly doesn't.\r\n\r\nRepro: https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVBjOA7AzgFzAEMAnEgLjAEEyiBPAHgH5sBXAWwCMBTEgPjABeMAG0AjABowbGDCkAmALroseQhhjci2GhWq1GbLrwHDSJAHRQAljHy8AFA6KUWHHiQCUlTnDibtIQEiMABCQWEZGE8AblQgA"}}
{"actor":{"display_login":"vkurchatkin"}}