【发布时间】:2021-04-04 12:31:38
【问题描述】:
我试图了解从我的操作函数返回的合适类型是什么: (将actions函数分成两个函数的结构是有意的)
type.ts:
export interface JsxActions {
init: (params: IProject, filterSearch ? : ISearch[]) => any;
}
export interface ApiFunc {
initCostDashboard: (params: IProject, filterSearch ? : ISearch[]) => any;
}
actions.ts:
export let jsxActions: JsxActions | Partial < JsxActions > = {};
jsxActions.init = function(params: IProject, filterSearch ? : ISearch[]): /* What will be return type */ {
return function(dispatch: Dispatch < AppActions > , getState: () => AppState) {
return api.initCostDashboard(params, filterSearch)(dispatch, getState);
};
};
export let api = {}
as ApiFunc;
api.initCostDashboard = function(params: IProject, filterSearch ? : ISearch[]) /* What will be return type */ {
return function(dispatch: Dispatch < AppActions > , getState: () => AppState) {
// ...Do something
}
}
谢谢
【问题讨论】:
标签: reactjs typescript react-typescript