declare namespace JSX { export type IntrinsicElements = { [index: string]: any } type ElementType = Fragment | string | Component type Element = DLElement interface ElementAttributesProperty { props: {} } interface ElementChildrenAttribute { children: {} } } declare function h( type: string | Component, props?: { [index: string]: any } | null, ...children: (HTMLElement | string)[] ): Node declare function $if( condition: DLPointer | any, then?: Element, otherwise?: Element ): HTMLElement type DLPointer = { readonly __symbol: unique symbol readonly __signature: T readonly value: T } declare function use(sink: T): DLPointer declare function use(sink: T, mapping: (arg: T) => R): DLPointer declare function use( template: TemplateStringsArray, ...params: any[] ): DLPointer type Stateful = T & { readonly symbol: unique symbol } declare function $state(target: T): Stateful declare function $store( target: T, options: { ident: string backing: | 'localstorage' | { read: () => string; write: (value: string) => void } autosave: 'auto' | 'manual' | 'beforeunload' } ): Stateful declare function useChange( references: DLPointer[] | DLPointer | T | T[], callback: (changedvalue: T) => void ): void declare function isDLPtr(ptr: any): boolean declare function isStateful(object: any): boolean declare function css(strings: TemplateStringsArray, ...values: any): string type DLCSS = string declare var $el: HTMLElement type Fragment = { readonly fragment: unique symbol } declare var Fragment: Fragment interface Element { $: OuterComponentTypes & { [index: string | symbol]: any } } interface DLElement extends HTMLElement { $: T & OuterComponentTypes } type ComponentElement any> = ReturnType type ComponentType any> = ReturnType['$'] type OuterComponentTypes = { root: Element children: Element[] } type InnerComponentTypes = { css: DLCSS mount?: () => void } type ComponentTypes = OuterComponentTypes & InnerComponentTypes type ArrayOrSingular = T | T[keyof T] /* start https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type */ type Intersect = (T extends any ? (x: T) => 0 : never) extends ( x: infer R ) => 0 ? R : never type TupleKeys = Exclude type Foo = { [K in TupleKeys]: { foo: T[K] } } type Values = T[keyof T] type Unfoo = T extends { foo: any } ? T['foo'] : never type IntersectItems = Unfoo>>> /* end https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type */ /* start https://stackoverflow.com/questions/52855145/typescript-object-type-to-array-type-tuple */ type LastOf = Intersect T : never> extends () => infer R ? R : never type Push = [...T, V] type TuplifyUnion< T, L = LastOf, N = [T] extends [never] ? true : false, > = true extends N ? [] : Push>, L> type ObjValueTuple< T, KS extends any[] = TuplifyUnion, R extends any[] = [], > = KS extends [infer K, ...infer KT] ? ObjValueTuple : R /* end https://stackoverflow.com/questions/52855145/typescript-object-type-to-array-type-tuple */ /* start https://stackoverflow.com/questions/53807517/how-to-test-if-two-types-are-exactly-the-same */ type IfEquals = (() => G extends T ? 1 : 2) extends () => G extends U ? 1 : 2 ? Y : N /* end https://stackoverflow.com/questions/53807517/how-to-test-if-two-types-are-exactly-the-same */ type ObjectAutogenProps = { [K in keyof Props]: | ({ [X in K]: Props[K] | DLPointer } & { [X in K as `bind:${Extract}`]?: never }) | ({ [X in K]?: never } & { [X in K as `bind:${Extract}`]: DLPointer }) } type AutogenProps = IntersectItems< ObjValueTuple> > type Component = ( this: Props & Private & Public & ComponentTypes, props: IfEquals, never, {}, AutogenProps> & { children?: ArrayOrSingular< Private extends { children: any } ? Private['children'] : Public extends { children: any } ? Public['children'] : never > 'bind:this'?: DLPointer< ComponentType> > } ) => DLElement