import type { ComputedRef, Ref, WatchOptions, WatchSource } from 'vue'; /** * Any function */ export type Fn = () => void; /** * A ref that allow to set null or undefined */ export type RemovableRef = Omit, 'value'> & { get value(): T; set value(value: T | null | undefined); }; /** * @deprecated Use `RemovableRef` */ export type RemoveableRef = RemovableRef; /** * Maybe it's a ref, or a plain value * * ```ts * type MaybeRef = T | Ref * ``` */ export type MaybeRef = T | Ref; /** * Maybe it's a ref, or a plain value, or a getter function * * ```ts * type MaybeComputedRef = (() => T) | T | Ref | ComputedRef * ``` */ export type MaybeComputedRef = MaybeReadonlyRef | MaybeRef; /** * Maybe it's a computed ref, or a getter function * * ```ts * type MaybeReadonlyRef = (() => T) | ComputedRef * ``` */ export type MaybeReadonlyRef = (() => T) | ComputedRef; /** * Make all the nested attributes of an object or array to MaybeRef * * Good for accepting options that will be wrapped with `reactive` or `ref` * * ```ts * UnwrapRef> === T * ``` */ export type DeepMaybeRef = T extends Ref ? MaybeRef : T extends any[] | object ? { [K in keyof T]: DeepMaybeRef; } : MaybeRef; /** * Infers the element type of an array */ export type ElementOf = T extends Array ? E : never; export type ShallowUnwrapRef = T extends Ref ? P : T; export type Awaitable = Promise | T; export type ArgumentsType = T extends (...args: infer U) => any ? U : never; export interface Pausable { /** * A ref indicate whether a pausable instance is active */ isActive: Ref; /** * Temporary pause the effect from executing */ pause: Fn; /** * Resume the effects */ resume: Fn; } export interface Stoppable { /** * A ref indicate whether a stoppable instance is executing */ isPending: Ref; /** * Stop the effect from executing */ stop: Fn; /** * Start the effects */ start: Fn; } /** * @deprecated Use `Stoppable` */ export type Stopable = Stoppable; export interface ConfigurableFlush { /** * Timing for monitoring changes, refer to WatchOptions for more details * * @default 'pre' */ flush?: WatchOptions['flush']; } export interface ConfigurableFlushSync { /** * Timing for monitoring changes, refer to WatchOptions for more details. * Unlike `watch()`, the default is set to `sync` * * @default 'sync' */ flush?: WatchOptions['flush']; } export type MapSources = { [K in keyof T]: T[K] extends WatchSource ? V : never; }; export type MapOldSources = { [K in keyof T]: T[K] extends WatchSource ? Immediate extends true ? V | undefined : V : never; };