danielroe/typed-vuex

docs: How do I reference $accessor inside a store's action tree?

Closed this issue · 3 comments

How do I correctly reference $accessor inside a store's action tree?

This works:

store.ts

export const actions = actionTree(
  { state, getters, mutations },
  {
          this.app.$accessor.foo.bar()

    },

.. but getting type error: TS7022: 'actions' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

vue-shim.d.ts

declare module '@nuxt/types' {
  interface NuxtAppOptions {
    $accessor: typeof accessorType
  }
}

TS2502: '$accessor' is referenced directly or indirectly in its own type annotation.

@simondib You'll need to add an explicit return type for that action.

https://nuxt-typed-vuex.roe.dev/actions#referencing-other-modules

Hope that helps 🙃

I'm closing this but do feel free to come back to me if that doesn't solve things for you 🙂

Thanks @danielroe 👍