Skip to main content

max / makenotwork

566 B · 19 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 interface HtmxApi {
8 ajax(method: string, url: string, target: string | { target: Element; swap?: string }): Promise<void>;
9 trigger(el: Element, name: string, detail?: unknown): void;
10 closest(el: Element, selector: string): Element | null;
11 }
12
13 declare global {
14 const htmx: HtmxApi;
15 interface Window {
16 htmx: HtmxApi;
17 }
18 }
19