direct-vuex icon indicating copy to clipboard operation
direct-vuex copied to clipboard

rootGetterContext expects different arguments than provided by the getter

Open jaredmcateer opened this issue 4 years ago • 2 comments

Following the example in the Readme I create a getter in my root store

getters: {
  myGetter(...args) {
    const {state, getters} = rootGetterContext(args);  
  }
}

I am getting the following type error

Argument of type '[RootState, any, any, any]' is not assignable to parameter of type '[any, any]'.
  Types of property 'length' are incompatible.
    Type '4' is not assignable to type '2'.ts(2345)

It seems to be expecting

(method) myGetter(state: RootState, getters: any, rootState: any, rootGetters: any): void

jaredmcateer avatar Mar 09 '20 20:03 jaredmcateer

As a workaround

myGetter(storeState, storeGetters): ExplicitType {
      const { state, getters } = rootGetterContext([storeState, storeGetters]);

seems to work

niklas-dahl avatar Jun 04 '21 09:06 niklas-dahl

I'm experiencing this same error with these versions:

  • vue: 2.6.11
  • vuex: 3.6.2
  • direct-vuex: 0.12.1

nerdybeast avatar Oct 04 '21 23:10 nerdybeast