Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect typing intellisense on store.state.counter.prop #1

Open
olemarius opened this issue Feb 25, 2021 · 1 comment
Open

Incorrect typing intellisense on store.state.counter.prop #1

olemarius opened this issue Feb 25, 2021 · 1 comment

Comments

@olemarius
Copy link

I've implemented this in a project that I also refactored from using mapState() to composition-api and computed(), but I'm not getting the correct typing intellisense in the component for state.

Your implementation, using getters
const counter = computed(() => store.getters.counterValue);

using state instead of getters
const counter = computed(() => store.state.counter1.counter1);

this gives the following error from VueDX, although it's works.
Property 'counter1' does not exist on type 'Counter1StoreModuleTypes<Counter1StateTypes>'.

While addgin .state clears the error, but doesn't work
const counter = computed(() => store.state.counter1.state.counter1);

@shubhadip
Copy link
Owner

this is probably because of the way store module are typed, we have to add type while access store data via state
const counterTemp = computed( () => ((store.state.counterModule as unknown) as CounterStateTypes).counter );
something like this. commit
also, just curious about any specific reason to use state instead of the getter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants