UNPKG

@sv-use/core

Version:

A collection of Svelte 5 utilities.

17 lines (16 loc) 763 B
type DefaultStateReturn<T> = { /** * @note Although it is typed as nullable, reading the value will never return a nullable value. * * This is to ensure that you can set a nullable value when changing the state without TS complaining. */ current: T | null | undefined; }; /** * A reactive state that falls back to `defaultValue` if set to `null` or `undefined`. * @param defaultValue The fallback value when the value is set to `null` or `undefined`. * @param initialValue The initial value of the state. Defaults to `defaultValue` if omitted. * @see https://svelte-librarian.github.io/sv-use/docs/core/default-state */ export declare function defaultState<T>(defaultValue: T, initialValue?: T): DefaultStateReturn<T>; export {};