From 2cc24bf8283a97255f3864efd15e7394e557b585 Mon Sep 17 00:00:00 2001 From: Kia Ishii Date: Thu, 30 Apr 2020 21:51:12 +0900 Subject: [PATCH] types: add `useStore` function (#1736) fix #1736 --- types/index.d.ts | 2 ++ types/test/index.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) 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: {