reduced typings some more

This commit is contained in:
Ken
2019-01-31 14:45:33 -08:00
parent 2ecb667b3a
commit 886215cefa
4 changed files with 26 additions and 18 deletions

View File

@@ -7,3 +7,8 @@ export function action<T extends string, P>(type: T, payload: P): ActionWithPayl
export function action<T extends string, P>(type: T, payload?: P) {
return { type, ...payload };
}
export type GenericActionMapping<A> = { [somekey in keyof A]: (...args: any) => Action<any> | ActionWithPayload<any, any> };
export type GenericActionTypes<A extends GenericActionMapping<A>> = ReturnType<A[keyof A]>['type'];
export type GenericAction<A extends GenericActionMapping<A>> = ReturnType<A[GenericActionTypes<A>]>;
export type GenericActionLookup<A extends GenericActionMapping<A>> = { [a in GenericActionTypes<A>]: ReturnType<A[a]> };