From 609e6386ce76133f138c7fb79cb56c5a6f571f0b Mon Sep 17 00:00:00 2001 From: Eduard Aksamitov Date: Mon, 27 Jul 2020 15:45:21 +0300 Subject: [PATCH 1/3] fix(types): add lost argument of useStore --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index c79587d94..e7ba16727 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -45,7 +45,7 @@ export declare class Store { export function createStore(options: StoreOptions): Store; -export function useStore(): Store; +export function useStore(key?: string): Store; export interface Dispatch { (type: string, payload?: any, options?: DispatchOptions): Promise; From 7a1da5a63cdce9c6e4e42352d1a8137361313d92 Mon Sep 17 00:00:00 2001 From: Eduard Aksamitov Date: Tue, 4 Aug 2020 15:32:52 +0300 Subject: [PATCH 2/3] fix(types): injectKey can be either InjectionKey or string --- types/index.d.ts | 4 ++-- types/test/index.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index e7ba16727..28365a2ec 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -15,7 +15,7 @@ export declare class Store { readonly state: S; readonly getters: any; - install(app: App, injectKey?: InjectionKey>): void; + install(app: App, injectKey?: InjectionKey> | string): void; replaceState(state: S): void; @@ -45,7 +45,7 @@ export declare class Store { export function createStore(options: StoreOptions): Store; -export function useStore(key?: string): Store; +export function useStore(injectKey?: InjectionKey> | string): Store; export interface Dispatch { (type: string, payload?: any, options?: DispatchOptions): Promise; diff --git a/types/test/index.ts b/types/test/index.ts index 7172b05d5..d7b2e28f8 100644 --- a/types/test/index.ts +++ b/types/test/index.ts @@ -1,3 +1,4 @@ +import { InjectionKey } from "vue"; import * as Vuex from "../index"; namespace StoreInstance { @@ -138,6 +139,14 @@ namespace UseStoreFunction { a: string } + const key: InjectionKey = Symbol('store') + + const storeWithKey = Vuex.useStore(key) + storeWithKey.state.a + + const storeWithKeyString = Vuex.useStore('store') + storeWithKeyString.state.a + const storeWithState = Vuex.useStore() storeWithState.state.a From 30bbfba46db5fbf5641ee4f5b75d2089041c8779 Mon Sep 17 00:00:00 2001 From: Eduard Aksamitov Date: Wed, 5 Aug 2020 15:32:07 +0300 Subject: [PATCH 3/3] fix(types): typo in generic --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 28365a2ec..5bca84755 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -45,7 +45,7 @@ export declare class Store { export function createStore(options: StoreOptions): Store; -export function useStore(injectKey?: InjectionKey> | string): Store; +export function useStore(injectKey?: InjectionKey> | string): Store; export interface Dispatch { (type: string, payload?: any, options?: DispatchOptions): Promise;