Skip to content

Commit 7bc63de

Browse files
author
Brynze Maxim
committed
fix(store): change types for overloads
1 parent 2863091 commit 7bc63de

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

types/index.d.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@ export declare class Store<S> {
2424
subscribeAction<P extends ActionPayload>(fn: SubscribeActionOptions<P, S>, options?: SubscribeOptions): () => void;
2525
watch<T>(getter: (state: S, getters: any) => T, cb: (value: T, oldValue: T) => void, options?: WatchOptions): () => void;
2626

27-
registerModule<T>(path: string, module: Module<T, S>, options?: ModuleOptions): void;
28-
registerModule<T>(path: string[], module: Module<T, S>, options?: ModuleOptions): void;
27+
registerModule<T>(path: string | string[], module: Module<T, S>, options?: ModuleOptions): void;
2928

30-
unregisterModule(path: string): void;
31-
unregisterModule(path: string[]): void;
29+
unregisterModule(path: string | string[]): void;
3230

33-
hasModule(path: string): boolean;
34-
hasModule(path: string[]): boolean;
31+
hasModule(path: string | string[]): boolean;
3532

3633
hotUpdate(options: {
3734
actions?: ActionTree<S, S>;

types/test/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ namespace RegisterModule {
342342
};
343343
}
344344

345+
function getInsideModulePath(): string | string[] {
346+
return Math.random() > 0.5 ? ["c"] : "c"
347+
}
348+
345349
const store = new Vuex.Store<RootState>({
346350
state: {
347351
value: 0
@@ -364,6 +368,12 @@ namespace RegisterModule {
364368

365369
store.hasModule(['a', 'b'])
366370

371+
store.registerModule(getInsideModulePath(), {
372+
state: {value: 3}
373+
})
374+
375+
store.hasModule(getInsideModulePath())
376+
367377
store.unregisterModule(["a", "b"]);
368378
store.unregisterModule("a");
369379
}

0 commit comments

Comments
 (0)