🍍 Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support
13.11k
stars
1.05k
forks
source link
Types appear broken and not unwrapping computed variables in getters #2484
Closed
silverbackdan closed 12 months ago
Reproduction
https://github.com/components-web-app/cwa-nuxt-module/tree/nuxt3/src/runtime/storage/stores/resources
Steps to reproduce the bug
I have defined a store like this:
https://github.com/components-web-app/cwa-nuxt-module/blob/nuxt3/src/runtime/storage/stores/resources/resources-store.ts
You can see the types I'm declaring here which was originally created as shorthands for types which were only internal: https://github.com/components-web-app/cwa-nuxt-module/blob/nuxt3/src/runtime/storage/stores/cwa-store-types.d.ts
When creating a store like this e.g.:
Typescript is now expecting me to access getters like:
Whereas it typed it properly before and I do not need the
.value
as computed vars are unwrapped. E.g.Expected behavior
I expected the types to be the same as before and to unwrap the getters. Am I missing a new type/interface?
Actual behavior
Although I access the computed getter references without
.value
- the type hinting expects me to use.value
which would actually result in a bug.Additional information
Hopefully it's a simple change which I've missed but I was looking a while and can't seem to see the solution yet.
Also, the type behaviour is the same if I remove the return type from the
useStore
method.