Skip to content

Commit

Permalink
types: add useStore function (#1736) (#1739)
Browse files Browse the repository at this point in the history
fix #1736
  • Loading branch information
kiaking authored Apr 30, 2020
1 parent f18d5d4 commit a934da9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export declare class Store<S> {

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

export function useStore<S = any>(): Store<S>;

export interface Dispatch {
(type: string, payload?: any, options?: DispatchOptions): Promise<any>;
<P extends Payload>(payloadWithType: P, options?: DispatchOptions): Promise<any>;
Expand Down
12 changes: 12 additions & 0 deletions types/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ namespace StoreInstance {
store.replaceState({ value: 10 });
}

namespace UseStoreFunction {
interface State {
a: string
}

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

const storeAsAny = Vuex.useStore()
storeAsAny.state.a
}

namespace RootModule {
const store = new Vuex.Store({
state: {
Expand Down

0 comments on commit a934da9

Please sign in to comment.