Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

docs: there some issue with vuex store doc #556

Open
hotrungnhan opened this issue Sep 18, 2021 · 3 comments
Open

docs: there some issue with vuex store doc #556

hotrungnhan opened this issue Sep 18, 2021 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@hotrungnhan
Copy link

hotrungnhan commented Sep 18, 2021

📚 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.

@hotrungnhan hotrungnhan added the documentation Improvements or additions to documentation label Sep 18, 2021
@hotrungnhan
Copy link
Author

i cant use vuex with typescript now , could you guy make a little example ?

@danielroe
Copy link
Member

@hotrungnhan Could you explain what you have tried and what isn't working for you? Ideally via a reproduction (https://template.nuxtjs.org).

@hotrungnhan
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants