{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/3367","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/3367/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/3367/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/3367/events","html_url":"https://github.com/facebook/flow/issues/3367","id":206947106,"number":3367,"title":"$Pick utility type","user":{"login":"mgtitimoli","id":4404683,"avatar_url":"https://avatars2.githubusercontent.com/u/4404683?v=4","gravatar_id":"","url":"https://api.github.com/users/mgtitimoli","html_url":"https://github.com/mgtitimoli","followers_url":"https://api.github.com/users/mgtitimoli/followers","following_url":"https://api.github.com/users/mgtitimoli/following{/other_user}","gists_url":"https://api.github.com/users/mgtitimoli/gists{/gist_id}","starred_url":"https://api.github.com/users/mgtitimoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgtitimoli/subscriptions","organizations_url":"https://api.github.com/users/mgtitimoli/orgs","repos_url":"https://api.github.com/users/mgtitimoli/repos","events_url":"https://api.github.com/users/mgtitimoli/events{/privacy}","received_events_url":"https://api.github.com/users/mgtitimoli/received_events","type":"User","site_admin":false},"labels":[{"id":149548105,"url":"https://api.github.com/repos/facebook/flow/labels/feature%20request","name":"feature request","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2017-02-11T01:38:47Z","updated_at":"2018-04-23T07:47:22Z","closed_at":null,"author_association":"NONE","body":"Hi there,\r\n\r\nI've just came across with the need of defining an object type using a subset of another, or in other words, use some props definition of a certain object type and intersect this result (a reduced object type) with another set of props definitions to define a new type.\r\n\r\nI used to do this a lot with PropTypes using pick utility from lodash, but we've recently moved to flow and I really miss this functionality, so I was wondering if you have ever thought of the possibility of adding a `$Pick` utility type to be able to do something like the following:\r\n\r\n```javascript\r\n// @flow\r\n\r\ntype O1 = {\r\n  o1k1: string,\r\n  o1k2: number,\r\n  o1k3: boolean,\r\n};\r\n\r\n// o1k1 and o1k2 mandatory\r\ntype O2 = $Pick<O1, o1k1 & o1k2> & {\r\n  o2k1: () => void,\r\n  o2k2: Date,\r\n};\r\n\r\n// o1k1 and o1k2 optional\r\ntype O2 = $Pick<O1, ?o1k1 & ?o1k2> & {\r\n  o2k1: () => void,\r\n  o2k2: Date,\r\n};\r\n```\r\n\r\nRight now I partially dealing with this using `$Shape` like the following, but this doesn't restrict additional props I don't want to, neither it let me mark any of them as required\r\n\r\n```javascript\r\n// @flow\r\n\r\ntype O1 = {\r\n  o1k1: string,\r\n  o1k2: number,\r\n  o1k3: boolean,\r\n};\r\n\r\ntype O2 = $Shape<O1> & {\r\n  o2k1: () => void,\r\n  o2k2: Date,\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/383484984","html_url":"https://github.com/facebook/flow/issues/3367#issuecomment-383484984","issue_url":"https://api.github.com/repos/facebook/flow/issues/3367","id":383484984,"user":{"login":"apsavin","id":632171,"avatar_url":"https://avatars0.githubusercontent.com/u/632171?v=4","gravatar_id":"","url":"https://api.github.com/users/apsavin","html_url":"https://github.com/apsavin","followers_url":"https://api.github.com/users/apsavin/followers","following_url":"https://api.github.com/users/apsavin/following{/other_user}","gists_url":"https://api.github.com/users/apsavin/gists{/gist_id}","starred_url":"https://api.github.com/users/apsavin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apsavin/subscriptions","organizations_url":"https://api.github.com/users/apsavin/orgs","repos_url":"https://api.github.com/users/apsavin/repos","events_url":"https://api.github.com/users/apsavin/events{/privacy}","received_events_url":"https://api.github.com/users/apsavin/received_events","type":"User","site_admin":false},"created_at":"2018-04-23T07:47:21Z","updated_at":"2018-04-23T07:47:21Z","author_association":"CONTRIBUTOR","body":"@TSMMark looks like another issue - see #5551"}}
{"actor":{"display_login":"apsavin"}}