sample code 既然创建者包含不确定数量的功能,有没有办法做到这一点?
const show = () => ({ type: "show" });
const setText = (text: string) => ({ type: "setText",payload: { text } });
const creators = {
show,setText
}
type actionCreators<T> = T[keyof T] extends (...args: any[]) => infer R ? R : never;
type A = actionCreators<typeof creators>;
// A = { type : string }
// expect A to be { type : string,payload : { text : string } }
// Is there a way to do that,since creators consist of an uncertain numbers of functions?