Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions types/helpers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type Dictionary<T> = { [key: string]: T };
type Computed = () => any;
type MutationMethod = (...args: any[]) => void;
type ActionMethod = (...args: any[]) => Promise<any>;
type CustomVue = Vue & Dictionary<any>

interface Mapper<R> {
(map: string[]): Dictionary<R>;
Expand All @@ -17,26 +18,26 @@ interface MapperWithNamespace<R> {
}

interface FunctionMapper<F, R> {
(map: Dictionary<(this: typeof Vue, fn: F, ...args: any[]) => any>): Dictionary<R>;
(map: Dictionary<(this: CustomVue, fn: F, ...args: any[]) => any>): Dictionary<R>;
}

interface FunctionMapperWithNamespace<F, R> {
(
namespace: string,
map: Dictionary<(this: typeof Vue, fn: F, ...args: any[]) => any>
map: Dictionary<(this: CustomVue, fn: F, ...args: any[]) => any>
): Dictionary<R>;
}

interface MapperForState {
<S>(
map: Dictionary<(this: typeof Vue, state: S, getters: any) => any>
map: Dictionary<(this: CustomVue, state: S, getters: any) => any>
): Dictionary<Computed>;
}

interface MapperForStateWithNamespace {
<S>(
namespace: string,
map: Dictionary<(this: typeof Vue, state: S, getters: any) => any>
map: Dictionary<(this: CustomVue, state: S, getters: any) => any>
): Dictionary<Computed>;
}

Expand Down
5 changes: 4 additions & 1 deletion types/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand Down