Skip to content

Commit 0e109e2

Browse files
davidsandozktsn
authored andcommitted
fix(types): Make mutation and action payload optional in definition file (#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
1 parent e262c36 commit 0e109e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

types/index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ export interface StoreOptions<S> {
9797
strict?: boolean;
9898
}
9999

100-
export type ActionHandler<S, R> = (this: Store<R>, injectee: ActionContext<S, R>, payload: any) => any;
100+
export type ActionHandler<S, R> = (this: Store<R>, injectee: ActionContext<S, R>, payload?: any) => any;
101101
export interface ActionObject<S, R> {
102102
root?: boolean;
103103
handler: ActionHandler<S, R>;
104104
}
105105

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

111111
export interface Module<S, R> {

0 commit comments

Comments
 (0)