{"action":"created","issue":{"url":"https://api.github.com/repos/borisyankov/DefinitelyTyped/issues/4640","labels_url":"https://api.github.com/repos/borisyankov/DefinitelyTyped/issues/4640/labels{/name}","comments_url":"https://api.github.com/repos/borisyankov/DefinitelyTyped/issues/4640/comments","events_url":"https://api.github.com/repos/borisyankov/DefinitelyTyped/issues/4640/events","html_url":"https://github.com/borisyankov/DefinitelyTyped/pull/4640","id":88248475,"number":4640,"title":"Add sample() to LoDashArrayWrapper interface","user":{"login":"nfantone","id":476069,"avatar_url":"https://avatars.githubusercontent.com/u/476069?v=3","gravatar_id":"","url":"https://api.github.com/users/nfantone","html_url":"https://github.com/nfantone","followers_url":"https://api.github.com/users/nfantone/followers","following_url":"https://api.github.com/users/nfantone/following{/other_user}","gists_url":"https://api.github.com/users/nfantone/gists{/gist_id}","starred_url":"https://api.github.com/users/nfantone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfantone/subscriptions","organizations_url":"https://api.github.com/users/nfantone/orgs","repos_url":"https://api.github.com/users/nfantone/repos","events_url":"https://api.github.com/users/nfantone/events{/privacy}","received_events_url":"https://api.github.com/users/nfantone/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-14T21:02:23Z","updated_at":"2015-06-14T21:40:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/borisyankov/DefinitelyTyped/pulls/4640","html_url":"https://github.com/borisyankov/DefinitelyTyped/pull/4640","diff_url":"https://github.com/borisyankov/DefinitelyTyped/pull/4640.diff","patch_url":"https://github.com/borisyankov/DefinitelyTyped/pull/4640.patch"},"body":"* Adds two additional definitions to `LoDashArrayWrapper` interface to allow usage of `sample()` functions in chains like so:\r\n\r\n```javascript\r\n_.chain([1,2,3,4]).sample().value()\r\n// or\r\n_.chain([1,2,3,4]).sample(2).value()\r\n```\r\n\r\n* Adds new lines to `lodash-tests.ts` that compiles said expressions."},"comment":{"url":"https://api.github.com/repos/borisyankov/DefinitelyTyped/issues/comments/111878028","html_url":"https://github.com/borisyankov/DefinitelyTyped/pull/4640#issuecomment-111878028","issue_url":"https://api.github.com/repos/borisyankov/DefinitelyTyped/issues/4640","id":111878028,"user":{"login":"nfantone","id":476069,"avatar_url":"https://avatars.githubusercontent.com/u/476069?v=3","gravatar_id":"","url":"https://api.github.com/users/nfantone","html_url":"https://github.com/nfantone","followers_url":"https://api.github.com/users/nfantone/followers","following_url":"https://api.github.com/users/nfantone/following{/other_user}","gists_url":"https://api.github.com/users/nfantone/gists{/gist_id}","starred_url":"https://api.github.com/users/nfantone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nfantone/subscriptions","organizations_url":"https://api.github.com/users/nfantone/orgs","repos_url":"https://api.github.com/users/nfantone/repos","events_url":"https://api.github.com/users/nfantone/events{/privacy}","received_events_url":"https://api.github.com/users/nfantone/received_events","type":"User","site_admin":false},"created_at":"2015-06-14T21:40:52Z","updated_at":"2015-06-14T21:40:52Z","body":"There's an edge case that I couldn't make it out. This,\r\n\r\n```javascript\r\n_.chain([1,2,3,4]).sample().value()\r\n```\r\n\r\nReturns a `number`, while specifying a parameter to `sample()` makes `value()` return an `Array<number>`.\r\n\r\nSo a function like this, does not compile, even though is totally correct:\r\n\r\n```javascript\r\nrelated(id:number):ng.IPromise<News> {\r\n\t\t\treturn this.list().then((response) => {\r\n\t\t\t\treturn _.chain(response).reject({id: id}).sample().value();\r\n\t\t\t});\r\n\t\t}\r\n```\r\n\r\nWhich throws \r\n````\r\nError:(41, 11) TS2322: Type 'IPromise<News[]>' is not assignable to type 'IPromise<News>'.\r\n  Type 'News[]' is not assignable to type 'News'.\r\n```"}}