Mithril.js: Possible to render fragment 'null' instead of '[' ?

Created on 12 Nov 2020  路  5Comments  路  Source: MithrilJS/mithril.js

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

Expected Behavior

I would like to be able to create Fragment in this form

// Fragment
m(null, null, m("div", null, 'hello'), m ("div", null, 'word'))

Current Behavior

Currently it is necessary to do so:

m('[', null, m("div", null, 'hello'), m("div", null, 'word'))

Context

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

Question

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikejav picture mikejav  路  3Comments

mke21 picture mke21  路  3Comments

hadihammurabi picture hadihammurabi  路  4Comments

josephys picture josephys  路  4Comments

isiahmeadows picture isiahmeadows  路  4Comments