我试图创建一个通用函数来在redux内部生成动作。我使用打字稿泛型来限制类型。请查看以下代码,并告诉我它是否正确。现在,它在有效负载上引发了错误
以下行引发错误。 defaultAPIAction.request())
export const createAction = <T>(type: string, error: boolean = false) =>
(payload: T , meta: any = null): {
type: string,
payload?: T,
meta?: any,
error: boolean,
} => ({ type, payload, meta, error });
/*
* This creates 3 constants respectively for EPIC calls only
* DEFAULT_API.REQUEST = 'form/REQUEST';
* DEFAULT_API.SUCCESS = 'form/SUCCESS';
* DEFAULT_API.FAILURE = 'form/FAILURE';
*/
export const defaultAPIAction = createApiAction(DEFAULT_API);