【发布时间】:2021-08-26 15:24:56
【问题描述】:
我有一个简单的 redux 传奇。
import { api } from '../api';
import * as screen from './slice';
import { fetchScreenSuccess } from './slice';
interface fetchScreenPayload {
screenName: string;
}
interface fetchScreenAction {
type: string;
payload: fetchScreenPayload;
}
function* fetchScreen(api: any, action: fetchScreenAction) {
...
}
export default function* watchDataSource() {
yield takeEvery(screen.fetchScreen, fetchScreen, api);
^^^^^^^^^^^^^^^^^^
Argument of type 'ActionCreatorWithoutPayload<string>' is not assignable to parameter of type 'TakeableChannel<unknown>'.
Property 'take' is missing in type 'ActionCreatorWithoutPayload<string>' but required in type 'TakeableChannel<unknown>'.
}
切片是:
export const screenSlice = createSlice({
name: 'screen',
// `createSlice` will infer the state type from the `initialState` argument
initialState,
reducers: {
fetchScreen(state): any {
state.screen = initialState.screen;
state.isLoading = true;
},
},
});
知道如何消除打字稿错误吗?
【问题讨论】:
标签: reactjs redux redux-saga