MithrilJS/mithril.d.ts

TypeScript: m.fragment without Attrs not allowed

Opened this issue · 1 comments

Error:

Expected 2 arguments, but got 1.ts(2554)
index.d.ts(57, 71): An argument for 'children' was not provided.

image

This can be solved by adding a second entry in the d.ts:

/** Creates a fragment virtual element (Vnode). */
fragment(attrs: Lifecycle<any, any> & { [key: string]: any }, children: ChildArrayOrPrimitive): Vnode<any, any>;
fragment(children: ChildArrayOrPrimitive): Vnode<any, any>;

@spacejack Also, the TS defs need updated to accept variadic children to align with the current hyperscript API (the ...args in m(Comp, ...args) and in m.fragment(...args) is handled the exact same way behind the scenes, so they should have identical prototypes).