Closed pkej closed 6 years ago
The same here. Since I don't think that it is reasonable to use typescript
without 100% type safety.
And I can clear see that vuex
does not support typing out-of-the box.
Here's an example to demonstrate my point:
// store/index.ts
export const actions = {
logoAction({ commit }, name: string) {
commit('SET_LOGO', name)
}
}
export const mutations = {
SET_LOGO(state: State, data: string) {
state.logo = data
}
}
// pages/SomeComponent.vue
import Vue from 'vue'
import Logo from '~/components/Logo.vue'
import Component from 'nuxt-class-component'
import { Getter, Action } from 'vuex-class'
@Component({
components: {
Logo
}
})
export default class extends Vue {
@Getter('logo/logo') logo
@Action('logo/logoAction') logoAction
created () {
this.logoAction(12) // no error here!!!
}
}
@pkej have you found any solution?
Sorry folks, I have no experience with nuxt, so can't comment here.
One option is to try and take this up with the author of vuex-type-safety. This guy forked from vuex-typex some time ago and may have an idea of how nuxt integrations could work.
From your documentation it seems this is a pattern, and as such I can't find any export I can use in a plugins context in nuxt.config.js, and since I'm just starting out With TypeScript I have no clue, except looking at code from different repositories, and Learning TypeScriptl
I hope you can advise on how to use it with Nuxt.