From 17c4e6b027c2985a4382565a85f680c8666647c9 Mon Sep 17 00:00:00 2001 From: Jacek Tomaszewski Date: Sun, 19 Apr 2020 16:14:07 +0200 Subject: [PATCH] Update types for mapXXX methods to work with spread operator. This worked as expected: ``` methods: { ...mapActions({ initStoreGroup: 'initStoreGroup' }), } ``` but this failed with message `Spread types may only be created from object types`: ``` methods: { ...mapActions(['initStoreGroup']), } ``` Commit fixes the problems. --- index.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index b27bca6..c17d3ca 100644 --- a/index.d.ts +++ b/index.d.ts @@ -515,7 +515,7 @@ export interface Mappers export interface MapperForGetters { - , U = { [P in K]: () => T[P] }>(keys: K[]): U; + >(keys: K[]): { [P in K]: () => T[P] }; , M extends { [key: string]: K }>(map: M): { [P in keyof M]: () => M[P] extends K ? T[M[P]] : never @@ -524,7 +524,7 @@ export interface MapperForGetters export interface MapperForState { - , U = { [P in K]: () => T[P] }>(keys: K[]): U; + >(keys: K[]): { [P in K]: () => T[P] }; , M extends { [key: string]: K | StateGetter }>(map: M): { [P in keyof M]: () => M[P] extends K ? T[M[P]] : ( @@ -535,7 +535,7 @@ export interface MapperForState export interface MapperForMutations { - , U = { [P in K]: (payload: MutationPayload) => void }>(keys: K[]): U; + >(keys: K[]): { [P in K]: (payload: MutationPayload) => void }; , M extends { [key: string]: K | MutationIn }>(map: M): { [P in keyof M]: M[P] extends keyof T @@ -546,7 +546,7 @@ export interface MapperForMutations export interface MapperForActions { - , U = { [P in K]: (payload: ActionPayload) => Promise> }>(keys: K[]): U; + >(keys: K[]): { [P in K]: (payload: ActionPayload) => Promise> }; , M extends { [key: string]: K | ActionIn }>(map: M): { [P in keyof M]: M[P] extends keyof T @@ -565,7 +565,7 @@ export interface MappersWithNamespace export interface MapperForGettersWithNamespace { - , U = { [P in K]: () => M[P] }>(namespace: ModulePath, keys: K[]): U; + >(namespace: ModulePath, keys: K[]): { [P in K]: () => M[P] }; , N extends { [key: string]: K }>(namespace: ModulePath, map: N): { [P in keyof N]: () => N[P] extends K ? M[N[P]] : never @@ -574,7 +574,7 @@ export interface MapperForGettersWithNamespace export interface MapperForStateWithNamespace { - , U = { [P in K]: () => M[P] }>(namespace: ModulePath, keys: K[]): U; + >(namespace: ModulePath, keys: K[]): { [P in K]: () => M[P] }; , N extends { [key: string]: K | StateGetter }>(namespace: ModulePath, map: N): { [P in keyof N]: () => N[P] extends K ? M[N[P]] : ( @@ -585,7 +585,7 @@ export interface MapperForStateWithNamespace export interface MapperForMutationsWithNamespace { - , U = { [P in K]: (payload: MutationPayload) => void }>(namespace: string, keys: K[]): U; + >(namespace: string, keys: K[]): { [P in K]: (payload: MutationPayload) => void }; , M extends { [key: string]: K | MutationIn }>(namespace: string, map: M): { [P in keyof M]: M[P] extends keyof T @@ -596,7 +596,7 @@ export interface MapperForMutationsWithNamespace export interface MapperForActionsWithNamespace { - , U = { [P in K]: (payload: ActionPayload) => Promise> }>(namespace: string, keys: K[]): U; + >(namespace: string, keys: K[]): { [P in K]: (payload: ActionPayload) => Promise> }; , M extends { [key: string]: K | ActionIn }>(namespace: string, map: M): { [P in keyof M]: M[P] extends keyof T @@ -624,4 +624,4 @@ declare const _default: { createNamespacedHelpers: typeof createNamespacedHelpers }; -export default _default; \ No newline at end of file +export default _default;