diff --git a/types/index.d.ts b/types/index.d.ts index 291f05ecf..1f4df9ca3 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -43,6 +43,8 @@ export declare class Store { export function createStore(options: StoreOptions): Store; +export function useStore(): Store; + export interface Dispatch { (type: string, payload?: any, options?: DispatchOptions): Promise;

(payloadWithType: P, options?: DispatchOptions): Promise; diff --git a/types/test/index.ts b/types/test/index.ts index b16ed9805..1c7f15b21 100644 --- a/types/test/index.ts +++ b/types/test/index.ts @@ -78,6 +78,18 @@ namespace StoreInstance { store.replaceState({ value: 10 }); } +namespace UseStoreFunction { + interface State { + a: string + } + + const storeWithState = Vuex.useStore() + storeWithState.state.a + + const storeAsAny = Vuex.useStore() + storeAsAny.state.a +} + namespace RootModule { const store = new Vuex.Store({ state: {