Skip to content

Add generic support to vuex hooks #157

Open
@Stoom

Description

@Stoom

Hello,

I've recently started to use vue-hooks for vuex. I've noticed that when creating a reactive state variable that expanding out useGetters returns an untyped dictionary. This causes typing issues in TS if you also have regular values as well. It can be overcome by first casting to unknown and then your type. I've noticed this also applies to the other vuex hooks. Would it be possible to support generics on the hooks to reduce the boilerplate?

const state = reactive({
            owner: '',
            ...useGetters(ProfileNS,[
              nameof<ProfileGetters>(x => x.picture),
              nameof<ProfileGetters>(x => x.name),
            ]) as unknown as { picture: string, name: string },

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions