it('calls after with the returned value', async () => {
const spy = jest.fn()
- store.$onAction(({ after }) => {
+ store.$onAction(({ after, name, store }) => {
+ name
+ if (name === 'upperName') {
+ after((ret) => {
+ // @ts-expect-error
+ ret * 2
+ ret.toUpperCase()
+ })
+ }
after(spy)
})
expect(store.upperName()).toBe('EDUARDO')
import type Vue from 'vue'
import {
- GenericStore,
GettersTree,
_Method,
StateTree,
keyof S | keyof G | ((store: Store<Id, S, G, A>) => any)
>
> = {
- [key in keyof T]: () => T[key] extends (store: GenericStore) => infer R
+ [key in keyof T]: () => T[key] extends (store: Store) => infer R
? R
: T[key] extends keyof S | keyof G
? Store<Id, S, G, A>[T[key]]
[
StoreWithState<string, StateTree>,
StateDescriptor<StateTree>,
- InjectionKey<GenericStore>
+ InjectionKey<Store>
]
>
>()
*
* @internal
*/
- _pStores?: Record<string, GenericStore>
+ _pStores?: Record<string, Store>
}
}
): [
StoreWithState<Id, S>,
{ get: () => S; set: (newValue: S) => void },
- InjectionKey<GenericStore>
+ InjectionKey<Store>
] {
const pinia = getActivePinia()
pinia.Vue.set(pinia.state.value, $id, initialState || buildState())
/**
* Generic version of Store.
+ * @deprecated Use Store instead
*/
-export type GenericStore = Store<
- string,
- StateTree,
- GettersTree<StateTree>,
- Record<string, _Method>
->
-
-/**
- * Generic version of `StoreDefinition`.
- */
-export type GenericStoreDefinition = StoreDefinition<
- string,
- StateTree,
- GettersTree<StateTree>,
- Record<string, _Method>
->
+export type GenericStore = Store
/**
* Properties that are added to every store by `pinia.use()`