{"action":"created","issue":{"url":"https://api.github.com/repos/yelouafi/redux-saga/issues/664","repository_url":"https://api.github.com/repos/yelouafi/redux-saga","labels_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/664/labels{/name}","comments_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/664/comments","events_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/664/events","html_url":"https://github.com/yelouafi/redux-saga/issues/664","id":192520504,"number":664,"title":"TypeScript. Run array of sagas in parallel.","user":{"login":"lysoff","id":5425414,"avatar_url":"https://avatars.githubusercontent.com/u/5425414?v=3","gravatar_id":"","url":"https://api.github.com/users/lysoff","html_url":"https://github.com/lysoff","followers_url":"https://api.github.com/users/lysoff/followers","following_url":"https://api.github.com/users/lysoff/following{/other_user}","gists_url":"https://api.github.com/users/lysoff/gists{/gist_id}","starred_url":"https://api.github.com/users/lysoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lysoff/subscriptions","organizations_url":"https://api.github.com/users/lysoff/orgs","repos_url":"https://api.github.com/users/lysoff/repos","events_url":"https://api.github.com/users/lysoff/events{/privacy}","received_events_url":"https://api.github.com/users/lysoff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-11-30T09:51:28Z","updated_at":"2016-11-30T14:05:56Z","closed_at":null,"body":"Actually, we are not using most of typescript features on the project, it's es6 all the way. Nevertheless, typescript compiler is still running and causes the following issue while trying to run sagas in parallel:\r\n\r\n```\r\nError:(32, 24) TS2345:Argument of type '() => IterableIterator<IterableIterator<TakeEffect<{}>>[]>' is not assignable to parameter of type 'SagaRest'.\r\n  Type 'IterableIterator<IterableIterator<TakeEffect<{}>>[]>' is not assignable to type 'IterableIterator<TakeEffect<any> | PutEffect<any> | RaceEffect | CallEffect | CpsEffect | ForkEff...'.\r\n    Type 'IterableIterator<TakeEffect<{}>>[]' is not assignable to type 'TakeEffect<any> | PutEffect<any> | RaceEffect | CallEffect | CpsEffect | ForkEffect | JoinEffect ...'.\r\n      Type 'IterableIterator<TakeEffect<{}>>[]' is not assignable to type 'Effect[]'.\r\n        Type 'IterableIterator<TakeEffect<{}>>' is not assignable to type 'Effect'.\r\n          Type 'IterableIterator<TakeEffect<{}>>' is not assignable to type 'CancelledEffect'.\r\n            Property 'CANCELLED' is missing in type 'IterableIterator<TakeEffect<{}>>'.\r\n```\r\n\r\nThere is a saga:\r\n```javascript\r\nimport { take } from 'redux-saga/effects';\r\nimport { SHOW_CONFIRM, HIDE_CONFIRM } from '../actions/constants';\r\n\r\nexport default function* confirmSaga() {\r\n    while (true) {\r\n        const { resolve, reject } = yield take(SHOW_CONFIRM);\r\n        const { isConfirmed } = yield take(HIDE_CONFIRM);\r\n        isConfirmed ? resolve() : reject();\r\n    }\r\n}\r\n```\r\nThere is a root saga (probably there will be more sagas in project, so, i guess we need this aggregation):\r\n```javascript\r\nimport confirmSaga from './confirmSaga'\r\n\r\nexport default function* rootSaga() {\r\n    yield [\r\n        confirmSaga()\r\n    ];\r\n};\r\n```\r\nConfiguring the store:\r\n```javascript\r\nimport rootSaga from 'sagas/';\r\n//...\r\nconst sagaMiddleware = createSagaMiddleware();\r\n//...\r\nconst middlewares = [\r\n//...\r\n  sagaMiddleware\r\n];\r\n//...\r\nsagaMiddleware.run(rootSaga); // <-- this line causes the error\r\n```\r\nAs i mentioned in the code, the ```run``` makes typescript compiler fail.\r\n\r\nSo, for now i run confirmSaga directly and it goes ok:\r\n```javascript\r\nsagaMiddleware.run(confirmSaga); // <-- ok\r\n```\r\nbut for sure we will add more sagas in future, so the issue is still there"},"comment":{"url":"https://api.github.com/repos/yelouafi/redux-saga/issues/comments/263881235","html_url":"https://github.com/yelouafi/redux-saga/issues/664#issuecomment-263881235","issue_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/664","id":263881235,"user":{"login":"aikoven","id":857709,"avatar_url":"https://avatars.githubusercontent.com/u/857709?v=3","gravatar_id":"","url":"https://api.github.com/users/aikoven","html_url":"https://github.com/aikoven","followers_url":"https://api.github.com/users/aikoven/followers","following_url":"https://api.github.com/users/aikoven/following{/other_user}","gists_url":"https://api.github.com/users/aikoven/gists{/gist_id}","starred_url":"https://api.github.com/users/aikoven/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aikoven/subscriptions","organizations_url":"https://api.github.com/users/aikoven/orgs","repos_url":"https://api.github.com/users/aikoven/repos","events_url":"https://api.github.com/users/aikoven/events{/privacy}","received_events_url":"https://api.github.com/users/aikoven/received_events","type":"User","site_admin":false},"created_at":"2016-11-30T14:05:56Z","updated_at":"2016-11-30T14:05:56Z","body":"Typings enforce you to always `yield` effects, not regular values or promises or generators. To get the most out of them, annotate return type of every saga with `SagaIterator`:\r\n```ts\r\nimport {SagaIterator} from \"redux-saga\";\r\n\r\nfunction* someSaga(): SagaIterator {\r\n  // ...\r\n}\r\n```\r\n\r\nIn your particular case you should replace this:\r\n```ts\r\n    yield [\r\n        confirmSaga()\r\n    ];\r\n```\r\nwith this:\r\n```ts\r\n    yield [\r\n        call(confirmSaga)\r\n    ];\r\n```"}}
{"actor":{"display_login":"aikoven"}}