Skip to content

Commit aa0b237

Browse files
committed
Add test for optional props
1 parent b6fa249 commit aa0b237

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Generated by ReScript, PLEASE EDIT WITH CARE
2+
3+
import * as Primitive_option from "rescript/lib/es6/Primitive_option.js";
4+
import * as JsxRuntime from "react/jsx-runtime";
5+
6+
function Jsx_optional_props_test$ComponentWithOptionalProps(props) {
7+
return null;
8+
}
9+
10+
let ComponentWithOptionalProps = {
11+
make: Jsx_optional_props_test$ComponentWithOptionalProps
12+
};
13+
14+
let _element = JsxRuntime.jsx(Jsx_optional_props_test$ComponentWithOptionalProps, {
15+
i: 1,
16+
s: "test",
17+
element: Primitive_option.some(JsxRuntime.jsx("div", {}))
18+
});
19+
20+
export {
21+
ComponentWithOptionalProps,
22+
_element,
23+
}
24+
/* _element Not a pure module */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@@config({flags: ["-bs-jsx", "4"]})
2+
3+
module ComponentWithOptionalProps = {
4+
@react.component
5+
let make = (
6+
~i as _: option<int>=?,
7+
~s as _: option<string>=?,
8+
~element as _: option<React.element>=?,
9+
) => React.null
10+
}
11+
12+
let _element = <ComponentWithOptionalProps i=1 s="test" element={<div />} />

tests/tests/src/jsx_preserve_test.mjs

+16
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,20 @@ let _large_component = <div
190190
</p>
191191
</div>;
192192

193+
function Jsx_preserve_test$ComponentWithOptionalProps(props) {
194+
return null;
195+
}
196+
197+
let ComponentWithOptionalProps = {
198+
make: Jsx_preserve_test$ComponentWithOptionalProps
199+
};
200+
201+
let _element = <Jsx_preserve_test$ComponentWithOptionalProps
202+
i={1}
203+
s="test"
204+
element={Primitive_option.some(<div />)}
205+
/>;
206+
193207
export {
194208
Icon,
195209
_single_element_child,
@@ -213,5 +227,7 @@ export {
213227
MyWeirdComponent,
214228
_escaped_jsx_prop,
215229
_large_component,
230+
ComponentWithOptionalProps,
231+
_element,
216232
}
217233
/* _single_element_child Not a pure module */

tests/tests/src/jsx_preserve_test.res

+11
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,14 @@ let _large_component =
115115
</strong>
116116
<p> {React.int(5)} </p>
117117
</div>
118+
119+
module ComponentWithOptionalProps = {
120+
@react.component
121+
let make = (
122+
~i as _: option<int>=?,
123+
~s as _: option<string>=?,
124+
~element as _: option<React.element>=?,
125+
) => React.null
126+
}
127+
128+
let _element = <ComponentWithOptionalProps i=1 s="test" element={<div />} />

0 commit comments

Comments
 (0)