// This file must stay a *module* (note the `export {}` at the bottom) so that // `declare global` is legal. A side-effect import of it from the package entry // (`import "./core/jsx"` in src/index.ts) is what pulls this global JSX // augmentation into any project that imports the package — without it, the // global `JSX` namespace would never reach consumers and they'd see // "JSX.IntrinsicElements is not defined". declare global { namespace JSX { // Fix: the old `type Element = Element | ...` was a circular self-reference. // Refer to the real DOM types via globalThis. type Element = | globalThis.Element | HTMLElement | DocumentFragment | Text | Comment; type StatefulSubscribable = { get(): T }; type MaybeSignal = T | StatefulSubscribable; type SignalCompatible = { [K in keyof T]: T[K] extends object ? MaybeSignal | SignalCompatible : MaybeSignal; }; /* ────────────────────────────────────────────────────────────────────── * Namespaced attribute syntax * * style:color={signal} → value typed as MaybeSignal * style:fontWeight="bold" → value typed from the matching CSS property * class:active={signal} → value typed as MaybeSignal (toggle) * * These are concrete template-literal keys, so they take priority over the * `[propName: string]: any` catch-all below — that's what gives you real * field-type checking instead of `any`. * ────────────────────────────────────────────────────────────────────── */ type StyleNamespace = { [K in keyof CSSStyleDeclaration as `style:${string & K}`]?: MaybeSignal; }; type ClassNamespace = { // class:foo toggles a single class — value is a (maybe-signal) boolean, // matching bind_attrs' `class.foo` semantics. [k: `class:${string}`]: MaybeSignal; }; type NamespacedAttributes = StyleNamespace & ClassNamespace; type IntrinsicElements = { [K in keyof HTMLElementTagNameMap]: // 1. Base HTML attributes, made signal-compatible (minus style/class, // which we type explicitly below). Omit>, "style" | "className"> // 2. Namespaced keys (style:*, class:*) with precise per-field types. & NamespacedAttributes & { // Whole-style prop: string or a signal-compatible CSS object. style?: MaybeSignal | SignalCompatible>; // Whole-class prop (both spellings your runtime accepts). class?: MaybeSignal; className?: MaybeSignal; // Catch-all for data-* and custom attributes. Kept as `unknown` // rather than `any` so it can't silently swallow type errors on // attributes you haven't explicitly declared; the specific keys // above still win for style:* / class:*. [propName: string]: unknown; children?: Element | Element[] | any; }; }; } } export {};