在一个观察者中有一个定义多个sagas的打字稿问题,我经常看到这种模式:
// foo.JS
export function *fooSagas() {
yield all([
takeEvery("FOO_A", fooASaga),
takeEvery("FOO_B", fooBSaga),
]);
}
但是当我尝试在打字稿文件中执行此操作时,我得到以下信息:
// foo.TS
export function *fooSagas() {
yield all([
takeEvery("FOO_A", fooASaga),
/*
all subsequent calls throw this typescript error:
The last overload gave the following error.
Argument of type 'string' is not assignable to parameter of type 'TakeableChannel<unknown>
effects.d.ts(291, 17): The last overload is declared here.
*/
takeEvery("FOO_B", fooBSaga),
]);
}
发布,以便我希望节省别人的时间...显然,这只是打字稿。
在每行之前添加// @ ts-ignore,一切正常
yield all ([
// @ts-ignore
takeLatest(ACT.todo.saga.create, create),
// @ts-ignore
takeLatest(ACT.todo.saga.retrieve, retrieve),
// @ts-ignore
takeLatest(ACT.todo.saga.update,update),
// @ts-ignore
takeLatest(ACT.todo.saga.delete,del),
// @ts-ignore
takeLatest(ACT.todo.saga.list, list)
])