composition-api
composition-api copied to clipboard
docs: there some issue with vuex store doc
📚 Is your documentation request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I feel I should be able to [...] but I can't see how to do it from the docs. i find out a little issue with vuex store. "userStore" interface is so diferent with vuex interface "userStore" which is
/// from vuex
useStore<S = any>(injectKey?: InjectionKey<Store<S>> | string): Store<S>;
/// from composition-api
useStore<S = any>(injectKey?: InjectionKey<S> | string): Store<S>;
So there will caught you have to import like
export const key: InjectionKey<State> = Symbol()
//instead of
import {Store} from 'vuex'
export const key: InjectionKey<Store<State>> = Symbol()
what ever it a feature or a bug , you might need to update new document for this 🔍 Where should you find it? What page of the docs do you expect this information to be found on?
//https://composition-api.nuxtjs.org/packages/store/
import { defineComponent, useStore } from '@nuxtjs/composition-api'
export interface State {
count: number
}
export const key: InjectionKey<Store<State>> = Symbol()
export default defineComponent({
setup() {
const store = useStore(key)
const store = useStore<State>()
// In both of these cases, store.state.count will be typed as a number
},
})
ℹ️ Additional context Add any other context or information.
i cant use vuex with typescript now , could you guy make a little example ?
@hotrungnhan Could you explain what you have tried and what isn't working for you? Ideally via a reproduction (https://template.nuxtjs.org).
https://codesandbox.io/s/eloquent-mccarthy-jv6n9?file=/pages/index.vue i write it on typescipt. just edit ~/store/index and pages/index.vue file