MithrilJS / mithril.d.ts

Types for mithril.js
MIT License
80 stars 11 forks source link

TypeScript: m.fragment without Attrs not allowed #43

Open ArthurClemens opened 3 years ago

ArthurClemens commented 3 years ago

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>;
dead-claudia commented 3 years ago

@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).