|
2 | 2 | flags: ["-bs-jsx", "4", "-bs-jsx-preserve"],
|
3 | 3 | })
|
4 | 4 |
|
5 |
| -module React = { |
6 |
| - type element = Jsx.element |
7 |
| - |
8 |
| - @val external null: element = "null" |
9 |
| - |
10 |
| - external float: float => element = "%identity" |
11 |
| - external int: int => element = "%identity" |
12 |
| - external string: string => element = "%identity" |
13 |
| - |
14 |
| - external array: array<element> => element = "%identity" |
15 |
| - |
16 |
| - type componentLike<'props, 'return> = Jsx.componentLike<'props, 'return> |
17 |
| - |
18 |
| - type component<'props> = Jsx.component<'props> |
19 |
| - |
20 |
| - external component: componentLike<'props, element> => component<'props> = "%identity" |
21 |
| - |
22 |
| - @module("react") |
23 |
| - external createElement: (component<'props>, 'props) => element = "createElement" |
24 |
| - |
25 |
| - @module("react") |
26 |
| - external cloneElement: (element, 'props) => element = "cloneElement" |
27 |
| - |
28 |
| - @module("react") |
29 |
| - external isValidElement: 'a => bool = "isValidElement" |
30 |
| - |
31 |
| - @variadic @module("react") |
32 |
| - external createElementVariadic: (component<'props>, 'props, array<element>) => element = |
33 |
| - "createElement" |
34 |
| - |
35 |
| - @module("react/jsx-runtime") |
36 |
| - external jsx: (component<'props>, 'props) => element = "jsx" |
37 |
| - |
38 |
| - @module("react/jsx-runtime") |
39 |
| - external jsxKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsx" |
40 |
| - |
41 |
| - @module("react/jsx-runtime") |
42 |
| - external jsxs: (component<'props>, 'props) => element = "jsxs" |
43 |
| - |
44 |
| - @module("react/jsx-runtime") |
45 |
| - external jsxsKeyed: (component<'props>, 'props, ~key: string=?, @ignore unit) => element = "jsxs" |
46 |
| - |
47 |
| - type fragmentProps = {children?: element} |
48 |
| - |
49 |
| - @module("react/jsx-runtime") external jsxFragment: component<fragmentProps> = "Fragment" |
50 |
| -} |
51 |
| - |
52 |
| -module ReactDOM = { |
53 |
| - external someElement: React.element => option<React.element> = "%identity" |
54 |
| - |
55 |
| - @module("react/jsx-runtime") |
56 |
| - external jsx: (string, JsxDOM.domProps) => Jsx.element = "jsx" |
57 |
| - |
58 |
| - @module("react/jsx-runtime") |
59 |
| - external jsxKeyed: (string, JsxDOM.domProps, ~key: string=?, @ignore unit) => Jsx.element = "jsx" |
60 |
| - |
61 |
| - @module("react/jsx-runtime") |
62 |
| - external jsxs: (string, JsxDOM.domProps) => Jsx.element = "jsxs" |
63 |
| - |
64 |
| - @module("react/jsx-runtime") |
65 |
| - external jsxsKeyed: (string, JsxDOM.domProps, ~key: string=?, @ignore unit) => Jsx.element = |
66 |
| - "jsxs" |
67 |
| -} |
68 |
| - |
69 | 5 | module Icon = {
|
70 | 6 | @react.component
|
71 | 7 | let make = () => {
|
@@ -179,3 +115,14 @@ let _large_component =
|
179 | 115 | </strong>
|
180 | 116 | <p> {React.int(5)} </p>
|
181 | 117 | </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 _optional_props = <ComponentWithOptionalProps i=1 s="test" element={<div />} /> |
0 commit comments