Skip to content

Commit 657afe3

Browse files
author
Eduard Aksamitov
authored
fix(types): add lost argument of useStore (#1803)
1 parent 2351c22 commit 657afe3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export declare class Store<S> {
1515
readonly state: S;
1616
readonly getters: any;
1717

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

2020
replaceState(state: S): void;
2121

@@ -45,7 +45,7 @@ export declare class Store<S> {
4545

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

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

5050
export interface Dispatch {
5151
(type: string, payload?: any, options?: DispatchOptions): Promise<any>;

types/test/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { InjectionKey } from "vue";
12
import * as Vuex from "../index";
23

34
namespace StoreInstance {
@@ -138,6 +139,14 @@ namespace UseStoreFunction {
138139
a: string
139140
}
140141

142+
const key: InjectionKey<string> = Symbol('store')
143+
144+
const storeWithKey = Vuex.useStore(key)
145+
storeWithKey.state.a
146+
147+
const storeWithKeyString = Vuex.useStore('store')
148+
storeWithKeyString.state.a
149+
141150
const storeWithState = Vuex.useStore<State>()
142151
storeWithState.state.a
143152

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy