I would like to make the Mithril Fragment evolve to correspond to what typescript expects.
Mithril version: : 2.0.4
Browser and OS: safari 14.0 and Mac OS 10.15.7
Project: : no link
I would like to be able to create Fragment in this form
// Fragment
m(null, null, m("div", null, 'hello'), m ("div", null, 'word'))
Currently it is necessary to do so:
m('[', null, m("div", null, 'hello'), m("div", null, 'word'))
I want to compile .tsx files and since a little while ago typescript offers an option jsxFragmentFactory but this one expects a function like the other frameworks or null.
https://github.com/microsoft/TypeScript/pull/38720#discussion_r440501615
@souricevincent
Didn't try it out, but would passing m.fragment in the compiler options for jsxFragmentFactory circumvent the whole situation?
@orbitbot
passing m.fragment in the typescript options jsxFragmentFactory doesn't work because it would give m(m.fragment, null, m('div', null, 'hello world')) and in mithril m.fragment is used as m.fragment(null, m('div', null, 'hello world')). And in Mithril, m.fragment(null, m('div', null, 'hello world')) is similar to m('[', null, m('div', null, 'hello world')). I can do a PR to change '[' by null to create a fragment
@orbitbot m.fragment does not work for JSX.
I would be open to an m.Fragment = '[' followed by lying about the type to TypeScript. (TypeScript makes far too many assumptions surrounding JSX, and there's an open issue I've commented in related to that.)
@isaaclyman m.Fragment = '[' It's a good idea, I'm doing PR soon.
As a political standpoint, I'm a bit weary of making changes just to appease 3rd party tools.