Skip to main content

max / makenotwork

651 B · 21 lines History Blame Raw
1 // Ambient declarations for the browser globals the core lib leans on.
2
3 export {};
4
5 /** The subset of the HTMX JS API the dispatcher uses. HTMX is loaded as a
6 * classic vendored script (`static/htmx.min.js`), so it's a global.
7 *
8 * `closest` was here until htmx 4 removed it: it was `Element.closest` with a
9 * null guard, so callers use the DOM method directly now. */
10 interface HtmxApi {
11 ajax(method: string, url: string, target: string | { target: Element; swap?: string }): Promise<void>;
12 trigger(el: Element, name: string, detail?: unknown): void;
13 }
14
15 declare global {
16 const htmx: HtmxApi;
17 interface Window {
18 htmx: HtmxApi;
19 }
20 }
21