declare 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 } } declare namespace VanX { type StateOf = { readonly [K in keyof T]: Van.State } type ValueType = T extends (infer V)[] ? V : T[keyof T] type KeyType = T extends unknown[] ? number : string type ReplacementFunc = T extends (infer V)[] ? (items: V[]) => readonly V[] : (items: [string, T[keyof T]][]) => readonly [string, T[keyof T]][] }