在ActionCollection也是对象的情况下如何解决此问题
源代码:
type ActionHandler = (...args: any) => IPayloadAction<any>
type ActionCollection = { [key: string]: ActionHandler }
export const buildResourceFromRedux = <A extends ActionCollection, S>(name: string, reduxModule: IRedux<A, S>) => {
return {
redux: reduxModule,
getResource: () => {
const store = getStore(reduxModule.reducer, reduxModule.saga, { name })
// Action
const action = dispatchAction(reduxModule.action, store.dispatch) as A
return {
store,
...action, ///////////////////////// Err here
...reduxModule,
}
},
}
}
我这样称呼数据的数据
buildResourceFromRedux('aUnitName', {
action: {
query: () => ({
type: 'QUERY',
}),
get: (id: string) => ({
type: 'GET',
payload: {
id,
}
})
},
saga: watchSaga*() {...}
reducer: (state, actions: Action<any>) => state
})
我正在使用打字稿3.1.2。