Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): add lost argument of useStore #1803

Merged
merged 3 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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<any>> | string): Store<S>;
euaaaio marked this conversation as resolved.
Show resolved Hide resolved

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