danielroe/typed-vuex

fix: useAccessor type is evaluating to `never` in Vue 3 (without Nuxt)

MaxLeiter opened this issue ยท 1 comments

๐Ÿ› The bug
a screenshot showing the type error

Whenever I try and access accessor the evaluated type is never. Did I do something wrong in setup?

๐Ÿ› ๏ธ To reproduce
Steps to reproduce the behavior:
Basic version of my code:

import {
	useAccessor,
	getterTree,
	mutationTree,
	actionTree,
} from 'typed-vuex'

export interface State {
...
}

const state = () => ({
...
} as State)

const getters = getterTree(state, {
....
})

const mutations = mutationTree(state, {
...
})

const actions = actionTree(
	{ state, getters, mutations },
	{
		...
	}
)

const storePattern = {
	state,
	mutations,
	actions,
}

const store = createStore(storePattern)


// Settings module is registered dynamically because it benefits
// from a direct reference to the store
store.registerModule("settings", createSettingsStore(store));

export const accessor = useAccessor(store, storePattern)

export type Accessor = typeof accessor;

๐ŸŒˆ Expected behaviour
It should be properly typed so I can use my store

โ„น๏ธ Additional context
I'm using Vue 3 if that matters; I didn't see anything about it in the docs.

This was due to bad typing on my end. a helpful tooltip elsewhere explained why it was evaluated to never.