TypeScript not recognizing type of destructured properties with storeToRefs and Vue 2 #2219
Unanswered
alexanderop
asked this question in
Help and Questions
Replies: 1 comment
-
Have the same issue ! storeToRefs doesnt type its return value correctly. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question:
I have been using Pinia with Vue 2 and have come across a TypeScript issue that I can't seem to resolve. I have a simple store like this:
In my component, I am trying to destructure the properties with
storeToRefs
:The problem is that TypeScript doesn't recognize that the destructured count is of type Ref. In Vue 3, it works as expected, but in Vue 2, TypeScript infers the type of count as any, which results in a loss of type safety.
I'm not sure why this is happening. Could anyone provide some insights or solutions to this issue? Any help would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions