export {} declare global { namespace Van { interface State { val: T readonly oldVal: T readonly rawVal: T } // Defining readonly view of State for covariance. // Basically we want StateView to implement StateView type StateView = Readonly> type Val = State | T type Primitive = string | number | boolean | bigint // deno-lint-ignore no-explicit-any type PropValue = Primitive | ((e: any) => void) | null type PropValueOrDerived = PropValue | StateView | (() => PropValue) type Props = Record & { class?: PropValueOrDerived; is?: string } type PropsWithKnownKeys = Partial<{[K in keyof ElementType]: PropValueOrDerived}> type ValidChildDomValue = Primitive | Node | null | undefined type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element) type ChildDom = ValidChildDomValue | StateView | BindingFunc | readonly ChildDom[] type TagFunc = (first?: Props & PropsWithKnownKeys | ChildDom, ...rest: readonly ChildDom[]) => Result type Tags = Readonly>> & { [K in keyof HTMLElementTagNameMap]: TagFunc } } const van:{ readonly state: (initVal: T, HMRKey?:string)=> Van.State readonly derive: (f: () => T) => Van.State readonly add: (dom: Element, ...children: readonly Van.ChildDom[]) => Element readonly tags: Van.Tags & ((namespaceURI: string) => Readonly>>) readonly hydrate: (dom: T, f: (dom: T) => T | null | undefined) => T }; }