* Plugin to extend every store
*/
export interface PiniaStorePlugin {
- (context: { app: App; store: GenericStore }): Partial<PiniaCustomProperties>
+ (context: {
+ app: App
+ store: GenericStore
+ }): Partial<PiniaCustomProperties> | void
}
/**
--- /dev/null
+import {
+ defineStore,
+ expectType,
+ mapStores,
+ createPinia,
+ GenericStore,
+} from '.'
+
+const useCounter = defineStore({
+ id: 'counter',
+ state: () => ({ n: 0 }),
+})
+
+type CounterStore = ReturnType<typeof useCounter>
+
+const computedStores = mapStores(useCounter)
+
+expectType<{
+ counterStore: () => CounterStore
+}>(computedStores)
+
+const pinia = createPinia()
+
+pinia.use(({ store }) => {
+ expectType<GenericStore>(store)
+})