From 657afe3db42c8d1d721216955fc2be3132e9fe6c Mon Sep 17 00:00:00 2001 From: Eduard Aksamitov Date: Tue, 11 Aug 2020 17:23:07 +0300 Subject: [PATCH] fix(types): add lost argument of useStore (#1803) --- 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 c79587d94..5bca84755 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(): 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