Przeglądaj źródła

update types for new helper signatures

Evan You 8 lat temu
rodzic
commit
8be59b4e52
2 zmienionych plików z 31 dodań i 0 usunięć
  1. 12 0
      types/helpers.d.ts
  2. 19 0
      types/test/helpers.ts

+ 12 - 0
types/helpers.d.ts

@@ -3,18 +3,30 @@ import Vue = require("vue");
 type Dictionary<T> = { [key: string]: T };
 
 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>;
 
 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>;

+ 19 - 0
types/test/helpers.ts

@@ -10,17 +10,28 @@ import {
 new Vue({
   computed: Object.assign({},
     mapState(["a"]),
+    mapState('foo', ["a"]),
     mapState({
       b: "b"
     }),
+    mapState('foo', {
+      b: "b"
+    }),
     mapState({
       c: (state: any, getters: any) => state.c + getters.c
     }),
+    mapState('foo', {
+      c: (state: any, getters: any) => state.c + getters.c
+    }),
 
     mapGetters(["d"]),
+    mapGetters('foo', ["d"]),
     mapGetters({
       e: "e"
     }),
+    mapGetters('foo', {
+      e: "e"
+    }),
 
     {
       otherComputed () {
@@ -34,11 +45,19 @@ new Vue({
     mapActions({
       h: "h"
     }),
+    mapActions('foo', ["g"]),
+    mapActions('foo', {
+      h: "h"
+    }),
 
     mapMutations(["i"]),
     mapMutations({
       j: "j"
     }),
+    mapMutations('foo', ["i"]),
+    mapMutations('foo', {
+      j: "j"
+    }),
 
     {
       otherMethod () {}