} from './rootStore'
export { defineStore, skipHydrate } from './store'
-export type { StoreActions, StoreGetters, StoreState } from './store'
+export type {
+ StoreActions,
+ StoreGetters,
+ StoreState,
+ SetupStoreDefinition,
+} from './store'
export type {
StateTree,
return useStore
}
+
+/**
+ * Return type of `defineStore()` with a setup function.
+ * - `Id` is a string literal of the store's name
+ * - `SS` is the return type of the setup function
+ * @see {@link StoreDefinition}
+ */
+export interface SetupStoreDefinition<Id extends string, SS>
+ extends StoreDefinition<
+ Id,
+ _ExtractStateFromSetupStore<SS>,
+ _ExtractGettersFromSetupStore<SS>,
+ _ExtractActionsFromSetupStore<SS>
+ > {}
-import { StoreDefinition } from './'
-import { computed, ref } from 'vue'
+import { ComputedRef, Ref, computed, ref } from 'vue'
import {
+ StoreDefinition,
+ SetupStoreDefinition,
StoreState,
StoreGetters,
StoreActions,
expectType<{ double: number }>(storeGetters(useOptionsStore))
-expectType<{ n: number }>(
- storeState(
- defineStore('', {
- state: () => ({ n: ref(0) }),
- })
- )
+expectType<
+ SetupStoreDefinition<
+ 'a',
+ {
+ n: Ref<number>
+ double: ComputedRef<number>
+ increment: () => void
+ }
+ >
+>(
+ defineStore('a', () => {
+ const n = ref(0)
+ const double = computed(() => n.value * 2)
+ function increment() {
+ n.value++
+ }
+ return {
+ double,
+ increment,
+ n,
+ }
+ })
)