From d0bd52dd2ffcd651b5f6aba123f2b146c36313e6 Mon Sep 17 00:00:00 2001 From: skepticattus Date: Thu, 23 Jul 2026 12:02:51 +0700 Subject: [PATCH] add ambient type declaration --- documentation/docs/02-runes/03-$derived.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/documentation/docs/02-runes/03-$derived.md b/documentation/docs/02-runes/03-$derived.md index a5a778af52..82d7ebda1b 100644 --- a/documentation/docs/02-runes/03-$derived.md +++ b/documentation/docs/02-runes/03-$derived.md @@ -65,6 +65,23 @@ let total = $derived(await a + b); On the other hand, values that are read _asynchronously_ (such as inside asynchronous closures passed to third-party query or observable libraries) will not be tracked automatically. To track these values, read them synchronously outside the asynchronous boundary. A clear pattern for this is to evaluate the dependencies using the `void` operator: ```js +// @filename: ambient.d.ts +declare module 'dexie' { + export class Dexie { + constructor(databaseName: string); + users: { + where(key: string): { + between(min: number, max: number): { + toArray(): Promise; + }; + }; + }; + } + export function liveQuery(querier: () => T | Promise): any; +} + +// @filename: index.js +// ---cut--- import { Dexie, liveQuery } from 'dexie'; const db = new Dexie('UserDatabase');