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

Add generic type to allow typing getters #2242

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions types/index.d.ts
Expand Up @@ -9,11 +9,11 @@ import { createLogger } from "./logger";
export * from "./helpers";
export * from "./logger";

export declare class Store<S> {
export declare class Store<S, G = any> {
constructor(options: StoreOptions<S>);

readonly state: S;
readonly getters: any;
readonly getters: G;

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

Expand All @@ -24,7 +24,7 @@ export declare class Store<S> {

subscribe<P extends MutationPayload>(fn: (mutation: P, state: S) => any, options?: SubscribeOptions): () => void;
subscribeAction<P extends ActionPayload>(fn: SubscribeActionOptions<P, S>, options?: SubscribeOptions): () => void;
watch<T>(getter: (state: S, getters: any) => T, cb: (value: T, oldValue: T) => void, options?: WatchOptions): () => void;
watch<T>(getter: (state: S, getters: G) => T, cb: (value: T, oldValue: T) => void, options?: WatchOptions): () => void;

registerModule<T>(path: string, module: Module<T, S>, options?: ModuleOptions): void;
registerModule<T>(path: string[], module: Module<T, S>, options?: ModuleOptions): void;
Expand Down