Skip to content

Commit

Permalink
fix(types): add lost argument of useStore (#1803)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard Aksamitov authored Aug 11, 2020
1 parent 2351c22 commit 657afe3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export declare class Store<S> {
readonly state: S;
readonly getters: any;

install(app: App, injectKey?: InjectionKey<Store<any>>): void;
install(app: App, injectKey?: InjectionKey<Store<any>> | string): void;

replaceState(state: S): void;

Expand Down Expand Up @@ -45,7 +45,7 @@ export declare class Store<S> {

export function createStore<S>(options: StoreOptions<S>): Store<S>;

export function useStore<S = any>(): Store<S>;
export function useStore<S = any>(injectKey?: InjectionKey<Store<S>> | string): Store<S>;

export interface Dispatch {
(type: string, payload?: any, options?: DispatchOptions): Promise<any>;
Expand Down
9 changes: 9 additions & 0 deletions types/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { InjectionKey } from "vue";
import * as Vuex from "../index";

namespace StoreInstance {
Expand Down Expand Up @@ -138,6 +139,14 @@ namespace UseStoreFunction {
a: string
}

const key: InjectionKey<string> = Symbol('store')

const storeWithKey = Vuex.useStore(key)
storeWithKey.state.a

const storeWithKeyString = Vuex.useStore('store')
storeWithKeyString.state.a

const storeWithState = Vuex.useStore<State>()
storeWithState.state.a

Expand Down

0 comments on commit 657afe3

Please sign in to comment.