From: Eduardo San Martin Morote Date: Tue, 27 Apr 2021 08:46:52 +0000 (+0200) Subject: feat(plugins): allow void return X-Git-Tag: v2.0.0-alpha.14~45 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=5ef71407764384bef13a4f46fd001beade387d24;p=thirdparty%2Fvuejs%2Fpinia.git feat(plugins): allow void return --- diff --git a/src/index.ts b/src/index.ts index 101dc7d4..39289f6e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,9 @@ export { defineStore } from './store' export { StateTree, Store, + GenericStore, + GenericStoreDefinition, + StoreDefinition, StoreWithGetters, StoreWithActions, StoreWithState, diff --git a/src/rootStore.ts b/src/rootStore.ts index a5874343..811b2002 100644 --- a/src/rootStore.ts +++ b/src/rootStore.ts @@ -60,7 +60,10 @@ export const getClientApp = () => clientApp * Plugin to extend every store */ export interface PiniaStorePlugin { - (context: { app: App; store: GenericStore }): Partial + (context: { + app: App + store: GenericStore + }): Partial | void } /** diff --git a/test-dts/plugins.test-d.ts b/test-dts/plugins.test-d.ts new file mode 100644 index 00000000..c1d542e2 --- /dev/null +++ b/test-dts/plugins.test-d.ts @@ -0,0 +1,26 @@ +import { + defineStore, + expectType, + mapStores, + createPinia, + GenericStore, +} from '.' + +const useCounter = defineStore({ + id: 'counter', + state: () => ({ n: 0 }), +}) + +type CounterStore = ReturnType + +const computedStores = mapStores(useCounter) + +expectType<{ + counterStore: () => CounterStore +}>(computedStores) + +const pinia = createPinia() + +pinia.use(({ store }) => { + expectType(store) +})