|
@@ -1,32 +1,52 @@
|
|
import Vue = require("vue");
|
|
import Vue = require("vue");
|
|
|
|
|
|
type Dictionary<T> = { [key: string]: T };
|
|
type Dictionary<T> = { [key: string]: T };
|
|
|
|
+type Computed = () => any;
|
|
|
|
+type MutationMethod = (...args: any[]) => void;
|
|
|
|
+type ActionMethod = (...args: any[]) => Promise<any>;
|
|
|
|
|
|
-export function mapState (map: string[]): Dictionary<() => any>;
|
|
|
|
-export function mapState (namespace: string, map: string[]): Dictionary<() => any>;
|
|
|
|
-export function mapState (map: Dictionary<string>): Dictionary<() => any>;
|
|
|
|
-export function mapState (namespace: string, map: Dictionary<string>): Dictionary<() => any>;
|
|
|
|
-export function mapState <S>(
|
|
|
|
- map: Dictionary<(this: typeof Vue, state: S, getters: any) => any>
|
|
|
|
-): Dictionary<() => any>;
|
|
|
|
-export function mapState <S>(
|
|
|
|
- namespace: string,
|
|
|
|
- map: Dictionary<(this: typeof Vue, state: S, getters: any) => any>
|
|
|
|
-): Dictionary<() => any>;
|
|
|
|
|
|
+interface Mapper<R> {
|
|
|
|
+ (map: string[]): Dictionary<R>;
|
|
|
|
+ (map: Dictionary<string>): Dictionary<R>;
|
|
|
|
+}
|
|
|
|
|
|
-type MutationMethod = (...args: any[]) => void;
|
|
|
|
-export function mapMutations (map: string[]): Dictionary<MutationMethod>;
|
|
|
|
-export function mapMutations (namespace: string, map: string[]): Dictionary<MutationMethod>;
|
|
|
|
-export function mapMutations (map: Dictionary<string>): Dictionary<MutationMethod>;
|
|
|
|
-export function mapMutations (namespace: string, map: Dictionary<string>): Dictionary<MutationMethod>;
|
|
|
|
-
|
|
|
|
-export function mapGetters (map: string[]): Dictionary<() => any>;
|
|
|
|
-export function mapGetters (namespace: string, map: string[]): Dictionary<() => any>;
|
|
|
|
-export function mapGetters (map: Dictionary<string>): Dictionary<() => any>;
|
|
|
|
-export function mapGetters (namespace: string, map: Dictionary<string>): Dictionary<() => any>;
|
|
|
|
-
|
|
|
|
-type ActionMethod = (...args: any[]) => Promise<any[]>;
|
|
|
|
-export function mapActions (map: string[]): Dictionary<ActionMethod>;
|
|
|
|
-export function mapActions (namespace: string, map: string[]): Dictionary<ActionMethod>;
|
|
|
|
-export function mapActions (map: Dictionary<string>): Dictionary<ActionMethod>;
|
|
|
|
-export function mapActions (namespace: string, map: Dictionary<string>): Dictionary<ActionMethod>;
|
|
|
|
|
|
+interface MapperWithNamespace<R> {
|
|
|
|
+ (namespace: string, map: string[]): Dictionary<R>;
|
|
|
|
+ (namespace: string, map: Dictionary<string>): Dictionary<R>;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+interface MapperForState {
|
|
|
|
+ <S>(
|
|
|
|
+ map: Dictionary<(this: typeof Vue, state: S, getters: any) => any>
|
|
|
|
+ ): Dictionary<Computed>;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+interface MapperForStateWithNamespace {
|
|
|
|
+ <S>(
|
|
|
|
+ namespace: string,
|
|
|
|
+ map: Dictionary<(this: typeof Vue, state: S, getters: any) => any>
|
|
|
|
+ ): Dictionary<Computed>;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+interface NamespacedMappers {
|
|
|
|
+ mapState: Mapper<Computed> & MapperForState;
|
|
|
|
+ mapMutations: Mapper<MutationMethod>;
|
|
|
|
+ mapGetters: Mapper<Computed>;
|
|
|
|
+ mapActions: Mapper<ActionMethod>;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+export declare const mapState: Mapper<Computed>
|
|
|
|
+ & MapperWithNamespace<Computed>
|
|
|
|
+ & MapperForState
|
|
|
|
+ & MapperForStateWithNamespace;
|
|
|
|
+
|
|
|
|
+export declare const mapMutations: Mapper<MutationMethod>
|
|
|
|
+ & MapperWithNamespace<MutationMethod>;
|
|
|
|
+
|
|
|
|
+export declare const mapGetters: Mapper<Computed>
|
|
|
|
+ & MapperWithNamespace<Computed>;
|
|
|
|
+
|
|
|
|
+export declare const mapActions: Mapper<ActionMethod>
|
|
|
|
+ & MapperWithNamespace<ActionMethod>;
|
|
|
|
+
|
|
|
|
+export declare function createNamespacedHelpers(namespace: string): NamespacedMappers;
|