Skip to content

Instantly share code, notes, and snippets.

@przemyslawjanpietrzak
Created October 31, 2021 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save przemyslawjanpietrzak/a6cc7ed0bc0bc6ee336e2bc7d93b12c9 to your computer and use it in GitHub Desktop.
Save przemyslawjanpietrzak/a6cc7ed0bc0bc6ee336e2bc7d93b12c9 to your computer and use it in GitHub Desktop.
literal-types-vuex.ts
interface Module1Actions {
actionA1(context: Module1ActionContext, payload: ActionA1Payload): void
actionA2(context: Module1ActionContext, payload: ActionA2Payload): void
}
type Module1ActionContext = {
dispatch<K extends keyof Module1Actions>(
actionType: K,
payload: Parameters<Module1Actions[K]>[1],
options?: DispatchOptions,
): ReturnType<Module1Actions[K]>;
commit<K extends keyof Module1Mutations>(
actionType: K,
payload Parameters<Module1Mutations[K]>[1]]
): ReturnType<Module1Mutations[K]>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment