u3u / vue-hooks

⚡️Awesome Vue Hooks
https://vue-hooks.netlify.com
MIT License
493 stars 33 forks source link

Add generic support to vuex hooks #157

Open Stoom opened 4 years ago

Stoom commented 4 years ago

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 },
issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.92. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.