我有下一个代码:
const sagaMiddleware = createSagaMiddleware(options);
.
.
.
const createdStore = createStore(
create(),
state,
someMiddleware,
) as someStore;
createdStore.runSaga = sagaMiddleware.run; // error here在升级到最新的redux-saga 1.1.3变体之前,它工作得很好。现在我得到了下一个错误:
Type '<S extends Saga<any[]>>(saga: S, ...args: Parameters<S>) => Task' is not assignable to type '(saga: (() => IterableIterator<any>) | undefined, args: any) => any'.
Types of parameters 'saga' and 'saga' are incompatible.
Type '(() => IterableIterator<any>) | undefined' is not assignable to type 'Saga<any[]>'.
Type 'undefined' is not assignable to type 'Saga<any[]>'.怎么才能修好?
发布于 2020-02-16 11:06:31
我在使用redux-boilerplate-typescript时也遇到了同样的问题。最后,我在type/index.d.ts中执行了以下操作:
import { Saga } from '@redux-saga/types';然后我改变了
export interface InjectedStore extends Store {
injectedReducers: any;
injectedSagas: any;
runSaga(
saga: (() => IterableIterator<any>) | undefined,
args: any | undefined,
): any;
}至
export interface InjectedStore extends Store {
injectedReducers: any;
injectedSagas: any;
runSaga(
saga: Saga | (() => IterableIterator<any>) | undefined,
args: any | undefined,
): any;
}https://stackoverflow.com/questions/60049879
复制相似问题