Comments (3)
I pushed a new test at 40d0996 but I remember it wasn't possible to type this
and the first argument at the same time. On top of that, this
can be typed with other getters while the argument cannot.
In my tests, state
has type any
, so not sure how you manage to get that one but I don't think there is a way to support both this
and the argument types. If you want to give it a try or TS end up somehow supporting it, feel free to give it a try and open a pull request
from pinia.
I tried to do a quick hack of G extends Record<string, (this: { state: S } & A & G, state: S) => any>
but it doesn't work well, maybe because G
references itself there. It is indeed strange how this
stops being inferred once an argument type is declared.
from pinia.
I gave this a try to at least have the state as the first parameter but couldn't make all the existing type tests pass. It's on https://github.com/posva/pinia/tree/types/getters-state if anyone can help.
Ideally, one should be able to have an automatically inferred type for a getter like this:
double: state => state.count * 2
from pinia.
Related Issues (20)
- Allow not unwrapping refs when using store HOT 1
- storeToReadonly HOT 1
- Pinia playground doesn't work with option store HOT 2
- docs(fa): add persian documentation HOT 1
- Patching store returns compile error in vscode
- doc code font can be normal ?
- Caching getters on server with Nuxt2 is not working as expected HOT 3
- in ts getters using 'this' doesn't affect
- Issue with typescript
- undefined is not an object (evaluating 'pinia._s.has'),TypeError, useStore
- `mapState()` not working with Vue 3.4 HOT 4
- Pinia Nuxt module breaks the `createTestingPinia` helper in tests HOT 6
- pinia running Browser extensions not work HOT 2
- Reactivity loss when using pinia with @vue/compat HOT 4
- Combining setup stores results in a store with type never. HOT 2
- pinia tries to import default export from vue package
- When a computed ref is present in the setup function of a Pinia store, using mapState may lead to typing errors. HOT 3
- `storeToRefs` loses the original typings of refs/computeds in a setup store, "generalizes" them instead
- The document file "/interfaces/pinia.SetupStoreDefinition.md" is missing. HOT 1
- Unable to test setup store actions with watcher HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinia.