diff --git a/examples/components/todosComponent.js b/examples/components/todosComponent.js index 48b8a21..0df75ac 100644 --- a/examples/components/todosComponent.js +++ b/examples/components/todosComponent.js @@ -59,11 +59,7 @@ export function todosComponent({ todos= [ "Task A" ] }= {}){ ) } /** - * @type {ddeComponent< - * { textContent: ddeSignal, value: number }, - * HTMLLIElement, - * [ "click" ] - * >} + * @dispatch {number} remove * */ function todoComponent({ textContent, value }){ const { host }= scope; diff --git a/index.d.ts b/index.d.ts index 9ad0a79..95c38cf 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,16 +1,6 @@ -import { Signal } from "./signals"; -//TODO? -/** Is filled when function is succesfully called ⇒ and returns component's root element. */ -type Host= (extender?: ElementExtender)=> el | undefined; declare global { - /** - * `ref` is filled when function is succesfully called ⇒ and returns component's root element. - * */ - type ddeComponent< - A extends Record, - R extends Element, - T extends string[] = [] - >= (attrs: A, ref: Host)=> R & { _events: T }; + type ddeComponentAttributes= Record | undefined | string; + type ddeElementExtender= (element: El)=> El; } type ElementTagNameMap= HTMLElementTagNameMap & SVGElementTagNameMap & { '#text': Text @@ -48,43 +38,45 @@ type ElementAttributes & AttrsModified; export function assign(element: El, ...attrs_array: Partial>[]): El -type ElementExtender= (element: El)=> El; type TagNameFragment= "<>"; export function el( tag_name: TAG, attrs?: Partial>, - ...extenders: ElementExtender[] + ...extenders: ddeElementExtender[] ): ElementTagNameMap[TAG] export function el( tag_name: TagNameFragment, ): DocumentFragment -export function el)=> R>( - fComponent: T, - attrs?: Parameters, - ...extenders: ElementExtender>[] -): ReturnType + +export function el< + A extends ddeComponentAttributes, + C extends (attr: A)=> Element>( + fComponent: C, + attrs?: A, + ...extenders: ddeElementExtender>[] +): ReturnType export function dispatchEvent(element: HTMLElement, name: keyof DocumentEventMap): void; export function dispatchEvent(element: HTMLElement, name: string, data: any): void; interface On{ < - EE extends ElementExtender, - El extends ( EE extends ElementExtender ? El : never ), + EE extends ddeElementExtender, + El extends ( EE extends ddeElementExtender ? El : never ), Event extends keyof DocumentEventMap>( type: Event, listener: (this: El, ev: DocumentEventMap[Event]) => any, options?: AddEventListenerOptions ) : EE; connected< - EE extends ElementExtender, - El extends ( EE extends ElementExtender ? El : never ) + EE extends ddeElementExtender, + El extends ( EE extends ddeElementExtender ? El : never ) >( listener: (el: El) => any, options?: AddEventListenerOptions ) : EE; disconnected< - EE extends ElementExtender, - El extends ( EE extends ElementExtender ? El : never ) + EE extends ddeElementExtender, + El extends ( EE extends ddeElementExtender ? El : never ) >( listener: (el: El) => any, options?: AddEventListenerOptions @@ -92,9 +84,6 @@ interface On{ } export const on: On; -//TODO? -export type Fires= ( (...a: any[])=> any ) & { events: T }; - //TODO for SVG declare global{ interface HTMLDivElement{ append(...nodes: (Node | string)[]): HTMLDivElement; }