-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.d.ts
29 lines (23 loc) · 1.06 KB
/
helpers.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { CommitOptions, ActionContext, Store as OriginalStore } from "vuex";
/** Payload types */
export type HandlerWithPayload<Key, TypeKey> = (
payload: TypeKey,
root?: boolean
) => { type: keyof Key; payload: TypeKey; options?: CommitOptions };
export type HandlerWithoutPayload<Key> = (
root?: boolean
) => { type: keyof Key; options?: CommitOptions };
/** Create Root State helper */
export type StateLocalByDefault<S, R> = R extends undefined ? any : R;
/** Action payload helpers */
export type ActionWithPayload<State, TypeOfKey, RootState = undefined> = (
this: OriginalStore<StateLocalByDefault<State, RootState>>,
ctx: ActionContext<State, StateLocalByDefault<State, RootState>>,
handler: { payload: TypeOfKey }
) => void | Promise<any>;
export type ActionWithoutPayload<State, RootState = undefined> = (
this: OriginalStore<StateLocalByDefault<State, RootState>>,
ctx: ActionContext<State, StateLocalByDefault<State, RootState>>
) => void | Promise<any>;
/** Getters helpers */
export type GetterHelper<Getter> = { [K in keyof Getter]: Getter[K] };