diff --git a/mithril.d.ts b/mithril.d.ts index d89dde59..a5c24a6e 100644 --- a/mithril.d.ts +++ b/mithril.d.ts @@ -28,22 +28,6 @@ declare module _mithril { MithrilComponent> ): MithrilVirtualElement; - /** - * Initializes a component for use with m.render, m.mount, etc. - * - * @param component A component. - * @param args Arguments to optionally pass to the component. - * @return A component. - * - * @see m.render - * @see m.mount - * @see m - */ - ( - component: MithrilComponent, - ...args: any[] - ): MithrilComponent; - /** * Creates a virtual element for use with m.render, m.mount, etc. * @@ -67,18 +51,121 @@ declare module _mithril { * Initializes a component for use with m.render, m.mount, etc. * Shorthand for m.component. * - * @param selector A component. - * @param args Arguments to optionally pass to the component. - * @return A component. + * @param component A mithril component. + * @return A mithril component. * * @see m.render * @see m.mount * @see m.component */ - ( - component: MithrilComponent, - ...args: any[] - ): MithrilComponent; + ( + component: MithrilComponent + ): MithrilComponent; + + /** + * Initializes a component for use with m.render, m.mount, etc. + * Shorthand for m.component. + * + * @param component A parameterized component. + * @param arg1 First argument to bind to the component. + * @return A component bound with the supplied arguments. + * + * @see m.render + * @see m.mount + * @see m.component + */ + ( + component: ParameterizedMithrilComponent, + arg1: T1 + ): MithrilComponent; + + /** + * Initializes a component for use with m.render, m.mount, etc. + * Shorthand for m.component. + * + * @param component A parameterized component. + * @param arg1 First argument to bind to the component. + * @param arg2 Second argument to bind to the component. + * @return A component bound with the supplied arguments. + * + * @see m.render + * @see m.mount + * @see m.component + */ + ( + component: ParameterizedMithrilComponent, + arg1: T1, + arg2: T2 + ): MithrilComponent; + + /** + * Initializes a component for use with m.render, m.mount, etc. + * Shorthand for m.component. + * + * @param component A parameterized component. + * @param arg1 First argument to bind to the component. + * @param arg2 Second argument to bind to the component. + * @param arg3 Third argument to bind to the component. + * @return A component bound with the supplied arguments. + * + * @see m.render + * @see m.mount + * @see m.component + */ + ( + component: ParameterizedMithrilComponent, + arg1: T1, + arg2: T2, + arg3: T3 + ): MithrilComponent; + + /** + * Initializes a parameterized component for use with m.render, m.mount, etc. + * Shorthand for m.component. + * + * @param component A parameterized component. + * @param arg1 First argument to bind to the component. + * @param arg2 Second argument to bind to the component. + * @param arg3 Third argument to bind to the component. + * @param arg4 Fourth argument to bind to the component. + * @return A component bound with the supplied arguments. + * + * @see m.render + * @see m.mount + * @see m.component + */ + ( + component: ParameterizedMithrilComponent, + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4 + ): MithrilComponent; + + /** + * Initializes a parameterized component for use with m.render, m.mount, etc. + * Shorthand for m.component. + * + * @param component A parameterized component. + * @param arg1 First argument to bind to the component. + * @param arg2 Second argument to bind to the component. + * @param arg3 Third argument to bind to the component. + * @param arg4 Fourth argument to bind to the component. + * @param args Additional optional arguments which are not type checked. + * @return A component bound with the supplied arguments. + * + * @see m.render + * @see m.mount + * @see m.component + */ + ( + component: ParameterizedMithrilComponent, + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, + ...args:any[] + ): MithrilComponent; /** * Creates a getter-setter function that wraps a Mithril promise. Useful @@ -149,18 +236,116 @@ declare module _mithril { /** * Initializes a component for use with m.render, m.mount, etc. * - * @param selector A component. - * @param args Arguments to optionally pass to the component. - * @return A component. + * @param component A mithril component. + * @return A mithril component. * * @see m.render * @see m.mount * @see m */ - component( - component: MithrilComponent, + component( + component: MithrilComponent + ): MithrilComponent; + + /** + * Initializes a parameterized component for use with m.render, m.mount, etc. + * + * @param component A parameterized component. + * @param arg1 First argument to bind to the component. + * @return A component bound with the supplied arguments. + * + * @see m.render + * @see m.mount + * @see m + */ + component( + component: ParameterizedMithrilComponent, + arg1: T1 + ): MithrilComponent; + + /** + * Initializes a parameterized component for use with m.render, m.mount, etc. + * + * @param component A parameterized component. + * @param arg1 First argument to bind to the component. + * @param arg2 Second argument to bind to the component. + * @return A component bound with the supplied arguments. + * + * @see m.render + * @see m.mount + * @see m + */ + component( + component: ParameterizedMithrilComponent, + arg1: T1, + arg2: T2 + ): MithrilComponent; + + /** + * Initializes a parameterized component for use with m.render, m.mount, etc. + * + * @param component A parameterized component. + * @param arg1 First argument to bind to the component. + * @param arg2 Second argument to bind to the component. + * @param arg3 Third argument to bind to the component. + * @return A component bound with the supplied arguments. + * + * @see m.render + * @see m.mount + * @see m + */ + component( + component: ParameterizedMithrilComponent, + arg1: T1, + arg2: T2, + arg3: T3 + ): MithrilComponent; + + /** + * Initializes a parameterized component for use with m.render, m.mount, etc. + * + * @param component A parameterized component. + * @param arg1 First argument to bind to the component. + * @param arg2 Second argument to bind to the component. + * @param arg3 Third argument to bind to the component. + * @param arg4 Fourth argument to bind to the component. + * @return A component bound with the supplied arguments. + * + * @see m.render + * @see m.mount + * @see m + */ + component( + component: ParameterizedMithrilComponent, + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4 + ): MithrilComponent; + + /** + * Initializes a parameterized component for use with m.render, m.mount, etc. + * + * @param component A parameterized component. + * @param arg1 First argument to bind to the component. + * @param arg2 Second argument to bind to the component. + * @param arg3 Third argument to bind to the component. + * @param arg4 Fourth argument to bind to the component. + * @param args Additional optional arguments which are not type checked. + * @return A component bound with the supplied arguments. + * + * @see m.render + * @see m.mount + * @see m + */ + component( + component: ParameterizedMithrilComponent, + arg1: T1, + arg2: T2, + arg3: T3, + arg4: T4, ...args: any[] - ): MithrilComponent; + ): MithrilComponent; /** * Trust this string of HTML. @@ -599,6 +784,30 @@ declare module _mithril { view(ctrl: T): MithrilVirtualElement; } + /** + * This represents a parameterized MithrilComponent with up to six parameters, + * intended to be instantiated via m.component(). + * + * @see m + * @see m.component + */ + interface ParameterizedMithrilComponent { + /** + * The component's controller. + * + * @see m.component + */ + controller: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, ...args: any[]) => TController; + + + /** + * creates a view out of virtual elements. + * + * @see m.component + */ + view(ctrl: TController, arg1: T1, arg2: T2, arg3: T3, arg4: T4, ...args:any[]): MithrilVirtualElement; + } + /** * This is the base interface for property getter-setters *