{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/flow/issues/2333","repository_url":"https://api.github.com/repos/facebook/flow","labels_url":"https://api.github.com/repos/facebook/flow/issues/2333/labels{/name}","comments_url":"https://api.github.com/repos/facebook/flow/issues/2333/comments","events_url":"https://api.github.com/repos/facebook/flow/issues/2333/events","html_url":"https://github.com/facebook/flow/issues/2333","id":173114785,"node_id":"MDU6SXNzdWUxNzMxMTQ3ODU=","number":2333,"title":"Include covariant interfaces for Map, Set and Array","user":{"login":"jesseschalken","id":1559204,"node_id":"MDQ6VXNlcjE1NTkyMDQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1559204?v=4","gravatar_id":"","url":"https://api.github.com/users/jesseschalken","html_url":"https://github.com/jesseschalken","followers_url":"https://api.github.com/users/jesseschalken/followers","following_url":"https://api.github.com/users/jesseschalken/following{/other_user}","gists_url":"https://api.github.com/users/jesseschalken/gists{/gist_id}","starred_url":"https://api.github.com/users/jesseschalken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jesseschalken/subscriptions","organizations_url":"https://api.github.com/users/jesseschalken/orgs","repos_url":"https://api.github.com/users/jesseschalken/repos","events_url":"https://api.github.com/users/jesseschalken/events{/privacy}","received_events_url":"https://api.github.com/users/jesseschalken/received_events","type":"User","site_admin":false},"labels":[{"id":149548105,"node_id":"MDU6TGFiZWwxNDk1NDgxMDU=","url":"https://api.github.com/repos/facebook/flow/labels/feature%20request","name":"feature request","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":{"login":"avikchaudhuri","id":5328177,"node_id":"MDQ6VXNlcjUzMjgxNzc=","avatar_url":"https://avatars1.githubusercontent.com/u/5328177?v=4","gravatar_id":"","url":"https://api.github.com/users/avikchaudhuri","html_url":"https://github.com/avikchaudhuri","followers_url":"https://api.github.com/users/avikchaudhuri/followers","following_url":"https://api.github.com/users/avikchaudhuri/following{/other_user}","gists_url":"https://api.github.com/users/avikchaudhuri/gists{/gist_id}","starred_url":"https://api.github.com/users/avikchaudhuri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avikchaudhuri/subscriptions","organizations_url":"https://api.github.com/users/avikchaudhuri/orgs","repos_url":"https://api.github.com/users/avikchaudhuri/repos","events_url":"https://api.github.com/users/avikchaudhuri/events{/privacy}","received_events_url":"https://api.github.com/users/avikchaudhuri/received_events","type":"User","site_admin":false},"assignees":[{"login":"avikchaudhuri","id":5328177,"node_id":"MDQ6VXNlcjUzMjgxNzc=","avatar_url":"https://avatars1.githubusercontent.com/u/5328177?v=4","gravatar_id":"","url":"https://api.github.com/users/avikchaudhuri","html_url":"https://github.com/avikchaudhuri","followers_url":"https://api.github.com/users/avikchaudhuri/followers","following_url":"https://api.github.com/users/avikchaudhuri/following{/other_user}","gists_url":"https://api.github.com/users/avikchaudhuri/gists{/gist_id}","starred_url":"https://api.github.com/users/avikchaudhuri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avikchaudhuri/subscriptions","organizations_url":"https://api.github.com/users/avikchaudhuri/orgs","repos_url":"https://api.github.com/users/avikchaudhuri/repos","events_url":"https://api.github.com/users/avikchaudhuri/events{/privacy}","received_events_url":"https://api.github.com/users/avikchaudhuri/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2016-08-25T05:05:12Z","updated_at":"2018-08-04T04:45:41Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Code is often written in terms of arrays with the expectation that if `B` fits `A` then `Array<B>` fits `Array<A>`. This is not true because `Array` is (correctly) invariant in its type parameter due to methods such as `push()`.\n\n``` js\nclass A {\n}\nclass B extends A {\n}\n\nfunction needsAs(as:Array<A>):void {\n  as.map(a => {/*...*/});\n}\n\nlet bs:Array<B> = [new B()];\n\nneedsAs(bs);\n```\n\n```\n8: function needsAs(as:Array<A>):void {\n                             ^ A. This type is incompatible with\n12: let bs:Array<B> = [new B()];\n                 ^ B\n```\n\nThis can be fixed by changing `needsAs` to `needsAs<T:A>(as:Array<T>):void`. However, it would be more convenient if there was a covariant interface for `Array` such as `ConstArray<+T>` that could be used instead so that the type parameter is not needed.\n\nSimilarly for `Map` and `Set`.\n"},"comment":{"url":"https://api.github.com/repos/facebook/flow/issues/comments/410423297","html_url":"https://github.com/facebook/flow/issues/2333#issuecomment-410423297","issue_url":"https://api.github.com/repos/facebook/flow/issues/2333","id":410423297,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDQyMzI5Nw==","user":{"login":"gnprice","id":28173,"node_id":"MDQ6VXNlcjI4MTcz","avatar_url":"https://avatars1.githubusercontent.com/u/28173?v=4","gravatar_id":"","url":"https://api.github.com/users/gnprice","html_url":"https://github.com/gnprice","followers_url":"https://api.github.com/users/gnprice/followers","following_url":"https://api.github.com/users/gnprice/following{/other_user}","gists_url":"https://api.github.com/users/gnprice/gists{/gist_id}","starred_url":"https://api.github.com/users/gnprice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnprice/subscriptions","organizations_url":"https://api.github.com/users/gnprice/orgs","repos_url":"https://api.github.com/users/gnprice/repos","events_url":"https://api.github.com/users/gnprice/events{/privacy}","received_events_url":"https://api.github.com/users/gnprice/received_events","type":"User","site_admin":false},"created_at":"2018-08-04T04:45:41Z","updated_at":"2018-08-04T04:45:41Z","author_association":"NONE","body":"There seems to be one of these for Array now, namely `$ReadOnlyArray`.\r\n\r\nIt's not in the docs anywhere I can find. But it is mentioned in the v0.38.0 release notes: https://github.com/facebook/flow/releases/tag/v0.38.0 and on #2811 .\r\n\r\nI don't know a way to do this for Set or Map, though.\r\n"}}
{"actor":{"display_login":"gnprice"}}