diff --git a/types/index.d.ts b/types/index.d.ts index 585b7d6b0..4c4e43e64 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -86,7 +86,7 @@ export interface StoreOptions { strict?: boolean; } -export type ActionHandler = (injectee: ActionContext, payload: any) => any; +export type ActionHandler = (this: Store, injectee: ActionContext, payload: any) => any; export interface ActionObject { root?: boolean; handler: ActionHandler; @@ -129,5 +129,5 @@ export interface ModuleTree { declare const _default: { Store: typeof Store; install: typeof install; -} +}; export default _default; diff --git a/types/test/index.ts b/types/test/index.ts index 0253e5df8..ca03458d9 100644 --- a/types/test/index.ts +++ b/types/test/index.ts @@ -59,6 +59,7 @@ namespace RootModule { }, actions: { foo ({ state, getters, dispatch, commit }, payload) { + this.state.value; state.value; getters.count; dispatch("bar", {}); @@ -83,6 +84,7 @@ namespace RootDefaultModule { }, actions: { foo ({ state, getters, dispatch, commit }, payload) { + this.state.value; state.value; getters.count; dispatch("bar", {}); @@ -107,7 +109,10 @@ namespace NestedModules { }; d: { value: number; - }; + }, + e: { + value: number; + } }; } @@ -145,7 +150,17 @@ namespace NestedModules { b: { modules: { c: module, - d: module + d: module, + e: { + state: { + value: 0 + }, + actions: { + foo(context: ActionStore, payload) { + this.state.a; + } + } + } } } }