Skip to content

Commit

Permalink
fix(types): Make mutation and action payload optional in definition f…
Browse files Browse the repository at this point in the history
…ile (#1517)

* Make mutation payload optional in definition file

When testing a mutation without payload in TypeScript, it complains that about the missing payload, even though it's not mandatory.

This PR simply makes the payload optional.

Fixes #1491

* Make action payload optional in definition file
  • Loading branch information
davidsandoz authored and ktsn committed Mar 10, 2019
1 parent e262c36 commit 0e109e2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions types/index.d.ts
Expand Up @@ -97,15 +97,15 @@ export interface StoreOptions<S> {
strict?: boolean;
}

export type ActionHandler<S, R> = (this: Store<R>, injectee: ActionContext<S, R>, payload: any) => any;
export type ActionHandler<S, R> = (this: Store<R>, injectee: ActionContext<S, R>, payload?: any) => any;
export interface ActionObject<S, R> {
root?: boolean;
handler: ActionHandler<S, R>;
}

export type Getter<S, R> = (state: S, getters: any, rootState: R, rootGetters: any) => any;
export type Action<S, R> = ActionHandler<S, R> | ActionObject<S, R>;
export type Mutation<S> = (state: S, payload: any) => any;
export type Mutation<S> = (state: S, payload?: any) => any;
export type Plugin<S> = (store: Store<S>) => any;

export interface Module<S, R> {
Expand Down

0 comments on commit 0e109e2

Please sign in to comment.