Redux saga typescript type error in yield all

Viewed 3588

I'm trying very simple example from redux-saga page.

function* saga(): SagaIterator {
  yield takeEvery(T.GET_CREDENTIALS, getCredentials);
}

export default function* rootSaga() {
  yield all([
    saga(),
  ]);
}

But I get typescript error:

Argument of type 'IterableIterator<RootEffect | TakeEffect | 
ChannelTakeEffect<any> | PutEffect<any> | ChannelPutEf...' is not 
assignable to parameter of type '{ [key: string]: Effect; }'.
Index signature is missing in type 'IterableIterator<RootEffect | 
TakeEffect | ChannelTakeEffect<any> | PutEffect<any> | 
ChannelPutEf...'.

What I'm doing wrong? Thanks for help

2 Answers

The examples in the redux-saga repository mostly use this form:

export default function* rootSaga() {
    yield all([
        fork(saga1),
        fork(saga2),
        // ...
    ])
}

See for instance their real-world example. I'm not sure what the point is of using fork instead of call when we are using all around it, since that helper alone should ensure parallel execution.

Related