From 9172da950c1ac8c00deaa93c97b32d383e035462 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Sun, 5 Nov 2017 13:33:42 +0800 Subject: [PATCH] fix: fix #1032, relax vue typing in helpers --- types/helpers.d.ts | 9 +++++---- types/test/helpers.ts | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/helpers.d.ts b/types/helpers.d.ts index e86650485..c7530151d 100644 --- a/types/helpers.d.ts +++ b/types/helpers.d.ts @@ -5,6 +5,7 @@ type Dictionary = { [key: string]: T }; type Computed = () => any; type MutationMethod = (...args: any[]) => void; type ActionMethod = (...args: any[]) => Promise; +type CustomVue = Vue & Dictionary interface Mapper { (map: string[]): Dictionary; @@ -17,26 +18,26 @@ interface MapperWithNamespace { } interface FunctionMapper { - (map: Dictionary<(this: typeof Vue, fn: F, ...args: any[]) => any>): Dictionary; + (map: Dictionary<(this: CustomVue, fn: F, ...args: any[]) => any>): Dictionary; } interface FunctionMapperWithNamespace { ( namespace: string, - map: Dictionary<(this: typeof Vue, fn: F, ...args: any[]) => any> + map: Dictionary<(this: CustomVue, fn: F, ...args: any[]) => any> ): Dictionary; } interface MapperForState { ( - map: Dictionary<(this: typeof Vue, state: S, getters: any) => any> + map: Dictionary<(this: CustomVue, state: S, getters: any) => any> ): Dictionary; } interface MapperForStateWithNamespace { ( namespace: string, - map: Dictionary<(this: typeof Vue, state: S, getters: any) => any> + map: Dictionary<(this: CustomVue, state: S, getters: any) => any> ): Dictionary; } diff --git a/types/test/helpers.ts b/types/test/helpers.ts index 460b692a4..569a9ecaf 100644 --- a/types/test/helpers.ts +++ b/types/test/helpers.ts @@ -41,7 +41,10 @@ new Vue({ k: "k" }), helpers.mapState({ - k: (state: any, getters: any) => state.k + getters.k + k: (state: any, getters: any) => state.k + getters.k, + useThis(state: any, getters: any) { + return state.k + getters.k + this.whatever + } }), helpers.mapGetters(["l"]),