mrcrowl / vuex-typex

Typescript builder for strongly-typed access to Vuex Store modules
MIT License
193 stars 22 forks source link

Type missmatch #12

Closed zelid closed 5 years ago

zelid commented 6 years ago

I get an error from the sample code:

dispatchRestoreSavedBasket: moduleBuilder.dispatch(restoreSavedBasket)

gives:

[ts]
Argument of type '(context: ActionContext<BasketState, RootState>) => Promise<void>' is not assignable to parameter of type 'ActionHandler<BasketState, RootState, {}, void>'.
  Types of parameters 'context' and 'context' are incompatible.
    Type 'BareActionContext<BasketState, RootState>' is not assignable to type 'ActionContext<BasketState, RootState>'.
      Property 'dispatch' is missing in type 'BareActionContext<BasketState, RootState>'.
const restoreSavedBasket: (context: ActionContext<BasketState, RootState>) => Promise<void>
    "vue": "^2.5.14",
    "vue-class-component": "^6.2.0",
    "vue-cookie": "1.1.4",
    "vue-loader": "^14.2.1",
    "vue-router": "^3.0.1",
    "vue-server-renderer": "^2.5.14",
    "vue-ssr-webpack-plugin": "^3.0.0",
    "vue-style-loader": "^4.0.2",
    "vue-template-compiler": "^2.5.14",
    "vuex": "^3.0.1",
    "vuex-class": "^0.3.0",
    "vuex-router-sync": "^5.0.0",
    "vuex-typex": "^3.0.1"
zelid commented 6 years ago

Figured it out: looks like in all examples context: ActionContext<BasketState, RootState> should be changed to context: BareActionContext<BasketState, RootState>

mrcrowl commented 5 years ago

Thanks. Updated readme and example gist now.