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

Support ref unwrapping in state #491

Closed
posva opened this issue May 10, 2021 · 2 comments
Closed

Support ref unwrapping in state #491

posva opened this issue May 10, 2021 · 2 comments
Labels
feature request typescript This issue is related to typings

Comments

@posva
Copy link
Member

posva commented May 10, 2021

Currently, passing a ref to the state is unwrapped because the store is a reactive object but the types do not reflect it:

const useStore = defineStore({ state: () => ({ n: ref(0) }) })

const store = useStore()
store.n // Ref<number> instead of number (the actual type)

This is useful to use external use* functions: #485 (reply in thread)

@posva posva added feature request typescript This issue is related to typings labels May 10, 2021
@philippedasilva-orizone
Copy link
Contributor

Any hint @posva where to look at exactly so that I don't get to understand the whole project but just focus on this part of the code? Or do you believe it'd have impacts on multiple parts?

@posva
Copy link
Member Author

posva commented May 10, 2021

I think this should be a possible contribution, using a type UnwrapRef from vue or inspiring yourself from the typing of reactive should help. It should be a typescript only change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request typescript This issue is related to typings
Projects
None yet
Development

No branches or pull requests

2 participants