Skip to content

Commit 21c8edb

Browse files
committed
fix(types): remove this annotation from mutations
1 parent 2c29024 commit 21c8edb

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

Diff for: types/index.d.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export declare class Store<S> {
2828

2929
hotUpdate(options: {
3030
actions?: ActionTree<S, S>;
31-
mutations?: MutationTree<S, S>;
31+
mutations?: MutationTree<S>;
3232
getters?: GetterTree<S, S>;
3333
modules?: ModuleTree<S>;
3434
}): void;
@@ -81,7 +81,7 @@ export interface StoreOptions<S> {
8181
state?: S;
8282
getters?: GetterTree<S, S>;
8383
actions?: ActionTree<S, S>;
84-
mutations?: MutationTree<S, S>;
84+
mutations?: MutationTree<S>;
8585
modules?: ModuleTree<S>;
8686
plugins?: Plugin<S>[];
8787
strict?: boolean;
@@ -95,15 +95,15 @@ export interface ActionObject<S, R> {
9595

9696
export type Getter<S, R> = (state: S, getters: any, rootState: R, rootGetters: any) => any;
9797
export type Action<S, R> = ActionHandler<S, R> | ActionObject<S, R>;
98-
export type Mutation<S, R> = (this: Store<R>, state: S, payload: any) => any;
98+
export type Mutation<S> = (state: S, payload: any) => any;
9999
export type Plugin<S> = (store: Store<S>) => any;
100100

101101
export interface Module<S, R> {
102102
namespaced?: boolean;
103103
state?: S | (() => S);
104104
getters?: GetterTree<S, R>;
105105
actions?: ActionTree<S, R>;
106-
mutations?: MutationTree<S, R>;
106+
mutations?: MutationTree<S>;
107107
modules?: ModuleTree<R>;
108108
}
109109

@@ -119,8 +119,8 @@ export interface ActionTree<S, R> {
119119
[key: string]: Action<S, R>;
120120
}
121121

122-
export interface MutationTree<S, R> {
123-
[key: string]: Mutation<S, R>;
122+
export interface MutationTree<S> {
123+
[key: string]: Mutation<S>;
124124
}
125125

126126
export interface ModuleTree<R> {

Diff for: types/test/index.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ namespace RootModule {
6767
}
6868
},
6969
mutations: {
70-
bar (state, payload) {
71-
this.state.value;
72-
}
70+
bar (state, payload) {}
7371
},
7472
strict: true
7573
});
@@ -94,9 +92,7 @@ namespace RootDefaultModule {
9492
}
9593
},
9694
mutations: {
97-
bar (state, payload) {
98-
this.state.value;
99-
}
95+
bar (state, payload) {}
10096
},
10197
strict: true
10298
});
@@ -163,11 +159,6 @@ namespace NestedModules {
163159
foo(context: ActionStore, payload) {
164160
this.state.a;
165161
}
166-
},
167-
mutations: {
168-
bar(state, payload) {
169-
this.state.b.e;
170-
}
171162
}
172163
}
173164
}

0 commit comments

Comments
 (0)