Skip to content

Commit 0efbe7b

Browse files
committed
Make Jsx.element a private empty record to avoid unnecessary Primitive_option.some
1 parent aa0b237 commit 0efbe7b

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

runtime/Jsx.res

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2424

25-
type element
25+
// Define this as a private empty record so that the compiler does not
26+
// unnecessarily add `Primitive_option.some` calls for optional props.
27+
type element = private {}
28+
2629
type ref
2730

2831
@val external null: element = "null"

tests/tests/src/jsx_optional_props_test.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

3-
import * as Primitive_option from "rescript/lib/es6/Primitive_option.js";
43
import * as JsxRuntime from "react/jsx-runtime";
54

65
function Jsx_optional_props_test$ComponentWithOptionalProps(props) {
@@ -14,7 +13,7 @@ let ComponentWithOptionalProps = {
1413
let _element = JsxRuntime.jsx(Jsx_optional_props_test$ComponentWithOptionalProps, {
1514
i: 1,
1615
s: "test",
17-
element: Primitive_option.some(JsxRuntime.jsx("div", {}))
16+
element: JsxRuntime.jsx("div", {})
1817
});
1918

2019
export {

tests/tests/src/jsx_preserve_test.mjs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

3-
import * as Primitive_option from "rescript/lib/es6/Primitive_option.js";
43
import * as JsxRuntime from "react/jsx-runtime";
54

65
function Jsx_preserve_test$Icon(props) {
@@ -25,7 +24,7 @@ let _multiple_element_children = <div>
2524
</div>;
2625

2726
let _single_element_fragment = <>
28-
{Primitive_option.some(<input />)}
27+
{<input />}
2928
</>;
3029

3130
let _multiple_element_fragment = <>
@@ -201,7 +200,7 @@ let ComponentWithOptionalProps = {
201200
let _element = <Jsx_preserve_test$ComponentWithOptionalProps
202201
i={1}
203202
s="test"
204-
element={Primitive_option.some(<div />)}
203+
element={<div />}
205204
/>;
206205

207206
export {

0 commit comments

Comments
 (0)