aboutsummaryrefslogtreecommitdiff
path: root/source/library/runes.d.ts
blob: 4b734820387826da1d22e105db40066af5a642b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*** EXPORT ------------------------------------------- ***/

/**
 * Ambient declarations for Svelte 5 runes so `deno check` can type-check
 * `.svelte.ts` files. The runtime forms are injected by the Svelte compiler.
 */

declare function $state<T>(initial: T): T;
declare function $state<T>(): T | undefined;

declare namespace $state {
  function raw<T>(initial: T): T;
  function raw<T>(): T | undefined;
  function snapshot<T>(value: T): T;
}

declare function $derived<T>(expression: T): T;

declare namespace $derived {
  function by<T>(fn: () => T): T;
}

declare function $effect(fn: () => void | (() => void)): void;

declare namespace $effect {
  function pre(fn: () => void | (() => void)): void;
  function root(fn: () => void | (() => void)): () => void;
  function tracking(): boolean;
}

declare function $props<T = Record<string, unknown>>(): T;
declare function $bindable<T>(fallback?: T): T;
declare function $inspect<T>(...values: T[]): { with: (fn: (type: "init" | "update", ...values: T[]) => void) => void };
declare function $host<T extends HTMLElement = HTMLElement>(): T;