diff --git a/.changeset/dirty-garlics-design.md b/.changeset/dirty-garlics-design.md new file mode 100644 index 0000000000..525160b762 --- /dev/null +++ b/.changeset/dirty-garlics-design.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +feat: add type of `$effect.active` diff --git a/packages/svelte/src/main/ambient.d.ts b/packages/svelte/src/main/ambient.d.ts index d80e8e4323..f32f1863e9 100644 --- a/packages/svelte/src/main/ambient.d.ts +++ b/packages/svelte/src/main/ambient.d.ts @@ -68,6 +68,28 @@ declare namespace $effect { * @param fn The function to execute */ export function pre(fn: () => void | (() => void)): void; + + /** + * The `$effect.active` rune is an advanced feature that tells you whether or not the code is running inside an effect or inside your template. + * + * Example: + * ```svelte + * + * + *

in template: {$effect.active()}

+ * ``` + * + * This allows you to (for example) add things like subscriptions without causing memory leaks, by putting them in child effects. + * + * https://svelte-5-preview.vercel.app/docs/runes#$effect-active + */ + export function active(): boolean; } /**