helpers.d.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import Vue = require("vue");
  2. type Dictionary<T> = { [key: string]: T };
  3. type Computed = () => any;
  4. type MutationMethod = (...args: any[]) => void;
  5. type ActionMethod = (...args: any[]) => Promise<any>;
  6. interface Mapper<R> {
  7. (map: string[]): Dictionary<R>;
  8. (map: Dictionary<string>): Dictionary<R>;
  9. }
  10. interface MapperWithNamespace<R> {
  11. (namespace: string, map: string[]): Dictionary<R>;
  12. (namespace: string, map: Dictionary<string>): Dictionary<R>;
  13. }
  14. interface MapperForState {
  15. <S>(
  16. map: Dictionary<(this: typeof Vue, state: S, getters: any) => any>
  17. ): Dictionary<Computed>;
  18. }
  19. interface MapperForStateWithNamespace {
  20. <S>(
  21. namespace: string,
  22. map: Dictionary<(this: typeof Vue, state: S, getters: any) => any>
  23. ): Dictionary<Computed>;
  24. }
  25. interface NamespacedMappers {
  26. mapState: Mapper<Computed> & MapperForState;
  27. mapMutations: Mapper<MutationMethod>;
  28. mapGetters: Mapper<Computed>;
  29. mapActions: Mapper<ActionMethod>;
  30. }
  31. export declare const mapState: Mapper<Computed>
  32. & MapperWithNamespace<Computed>
  33. & MapperForState
  34. & MapperForStateWithNamespace;
  35. export declare const mapMutations: Mapper<MutationMethod>
  36. & MapperWithNamespace<MutationMethod>;
  37. export declare const mapGetters: Mapper<Computed>
  38. & MapperWithNamespace<Computed>;
  39. export declare const mapActions: Mapper<ActionMethod>
  40. & MapperWithNamespace<ActionMethod>;
  41. export declare function createNamespacedHelpers(namespace: string): NamespacedMappers;