import type { MarkRequired } from "./types"; export function createElement( tagName: K, init?: string | ((e: HTMLElementTagNameMap[K]) => void) | null, ...children: (string | Node)[] ): HTMLElementTagNameMap[K]; export function createElement( tagName: string, init?: string | ((e: HTMLElement) => void) | null, ...children: (string | Node)[] ): HTMLElement; export function createElement( tagName: string, init?: string | ((e: any) => void) | null, ...children: (string | Node)[] ): HTMLElement { const el = document.createElement(tagName); if (typeof init === 'function') { init(el); } else if (init != null) { el.className = init; } if (children.length > 0) { el.append(...children); } return el; } export function mergeOptions>( defaults: D, opts?: T ): MarkRequired> { const result: Record = { ...defaults }; if (opts) { for (const [key, value] of Object.entries(opts)) { if (value !== undefined) { result[key] = value; } } } return result as MarkRequired>; }