How to properly typecast Pinia stores when using them with TypeScript & vue-facing-decorator ? #2573
Unanswered
Werns
asked this question in
Help and Questions
Replies: 1 comment 2 replies
-
Of course, not even an hour after asking and I've found what might be the solution. Should I be worried that the jsdocs for _GettersTree says it's for internal use only, though?
|
Beta Was this translation helpful? Give feedback.
2 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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! I'm migrating from Vue 2 to 3 and replacing Vuex with Pinia. My project was written with
vue-class-component
andvue-property-decorator
, so I'm also switching tovue-facing-decorator
. However, I'm running into a problem making these 2 libraries work together with Typescript.According to vfd's documentation, the way to inject composables is to use
@Setup
, so I'm trying to do that for Pinia stores but I'm running into trouble assigning a type for the the actualized store.Per the in-line comments, this throws various errors. If I get rid of the casting, it technically compiles but it's not quite right and there's no enforcement that the getters/actions defined in the
defineStore()
options are actually implemented theMyStoreGetters
andMyStoreActions
interfaces.I have also tried doing something like this, but I get an error that it's creating a store before Pinia is initialized.
What's the "proper" way of doing this? Or is there one?
Beta Was this translation helpful? Give feedback.
All reactions