{"action":"created","issue":{"url":"https://api.github.com/repos/oliviertassinari/react-event-listener/issues/36","repository_url":"https://api.github.com/repos/oliviertassinari/react-event-listener","labels_url":"https://api.github.com/repos/oliviertassinari/react-event-listener/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/oliviertassinari/react-event-listener/issues/36/comments","events_url":"https://api.github.com/repos/oliviertassinari/react-event-listener/issues/36/events","html_url":"https://github.com/oliviertassinari/react-event-listener/pull/36","id":215241893,"number":36,"title":"Making iteration over subset of props more explicit for Flow","user":{"login":"houshuang","id":61575,"avatar_url":"https://avatars2.githubusercontent.com/u/61575?v=3","gravatar_id":"","url":"https://api.github.com/users/houshuang","html_url":"https://github.com/houshuang","followers_url":"https://api.github.com/users/houshuang/followers","following_url":"https://api.github.com/users/houshuang/following{/other_user}","gists_url":"https://api.github.com/users/houshuang/gists{/gist_id}","starred_url":"https://api.github.com/users/houshuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houshuang/subscriptions","organizations_url":"https://api.github.com/users/houshuang/orgs","repos_url":"https://api.github.com/users/houshuang/repos","events_url":"https://api.github.com/users/houshuang/events{/privacy}","received_events_url":"https://api.github.com/users/houshuang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-19T05:07:06Z","updated_at":"2017-03-19T10:04:23Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/oliviertassinari/react-event-listener/pulls/36","html_url":"https://github.com/oliviertassinari/react-event-listener/pull/36","diff_url":"https://github.com/oliviertassinari/react-event-listener/pull/36.diff","patch_url":"https://github.com/oliviertassinari/react-event-listener/pull/36.patch"},"body":"This addresses #35. The problem is that currently, the code extracts an array of strings corresponding to the key names in the Props object, filters the list, which results in us knowing that target or children will not be part of the list. It then accesses the Props object with this list, however Flow cannot (in 0.42.0) follow the logic and understand that children or target could not be in the list, which causes the Flow error.\r\n\r\nHere's a minimal example which causes the same problem\r\n```\r\ntype Props = {\r\n  target?: EventTarget,\r\n  [event: string]: string\r\n};\r\n\r\nconst a = (x: Props) => {\r\n  Object.keys(x).forEach((name) => {\r\n    if (name.substring(0, 2) !== 'on') {\r\n      return;\r\n    }\r\n    console.log(x[name] + 'hi')\r\n  })\r\n}\r\n```\r\n\r\nBy explicitly destructuring the Props, and removing the two differently typed key-value pairs, Flow understands that only strings could be left, and lets us proceed. Thus no Flow error, and tests still pass."},"comment":{"url":"https://api.github.com/repos/oliviertassinari/react-event-listener/issues/comments/287606012","html_url":"https://github.com/oliviertassinari/react-event-listener/pull/36#issuecomment-287606012","issue_url":"https://api.github.com/repos/oliviertassinari/react-event-listener/issues/36","id":287606012,"user":{"login":"oliviertassinari","id":3165635,"avatar_url":"https://avatars1.githubusercontent.com/u/3165635?v=3","gravatar_id":"","url":"https://api.github.com/users/oliviertassinari","html_url":"https://github.com/oliviertassinari","followers_url":"https://api.github.com/users/oliviertassinari/followers","following_url":"https://api.github.com/users/oliviertassinari/following{/other_user}","gists_url":"https://api.github.com/users/oliviertassinari/gists{/gist_id}","starred_url":"https://api.github.com/users/oliviertassinari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliviertassinari/subscriptions","organizations_url":"https://api.github.com/users/oliviertassinari/orgs","repos_url":"https://api.github.com/users/oliviertassinari/repos","events_url":"https://api.github.com/users/oliviertassinari/events{/privacy}","received_events_url":"https://api.github.com/users/oliviertassinari/received_events","type":"User","site_admin":false},"created_at":"2017-03-19T10:04:23Z","updated_at":"2017-03-19T10:04:23Z","body":"@houshuang Thanks for the fix. I'm gonna continue the PR to fix the eslint error and upgrade flow 😄 ."}}
{"actor":{"display_login":"oliviertassinari"}}