Closed cristianoc closed 1 year ago
I'll look into it
Probably one need to add a type annotation just like in other cases : {} : props<_>
Or, in rescript-react
// React.res
type fragmentProps<'children> = {children?: 'children} // ? optional
then
React.jsx(React.jsxFragment, {})
It works fine
Or, in rescript-react
// React.res type fragmentProps<'children> = {children?: 'children} // ? optional
then
React.jsx(React.jsxFragment, {})
It works fine
This looks cleaner.
I'll make a PR soon.
The one thing to check is, that when children
is actually present, the compiler understands it's a record type inside, and does not add any of that runtime magic for optionals.
The one thing to check is, that when
children
is actually present, the compiler understands it's a record type inside, and does not add any of that runtime magic for optionals.
If I understand correctly, isn't it same to the uppercase and lowercase component too? Z.props
would have children props as optional and Jsx.domProps
has an optional children field already.
<Z /> // jsx(Z.make, {})
<Z> ... </Z> // jsx(Z.make, {children: ...})
<div /> // jsx("div", {})
<div> ... </div> // jsx("div", {children: ... })
I think the current type fragmentProps
is wrong. The children field should be optional as we discussed, because the fragment could have children or not.
This:
produces:
which gives a type errow (without location information):