Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit d15b125

Browse files
committed
test: add test files
1 parent 2995a6d commit d15b125

6 files changed

+83
-49
lines changed
+11-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
@obj external makeProps: (~msg: 'msg, ~key: string=?, unit) => {"msg": 'msg} = "" // test React JSX file
1+
type props<'msg> = { // test React JSX file
2+
@optional key: string,
3+
@optional ref: React.ref<Js.Nullable.t<Dom.element>>,
4+
msg: 'msg,
5+
}
6+
7+
let make = ({msg, ref}: props<'msg>) => {
8+
let _ = ref
29

3-
let make =
4-
(@warning("-16") ~msg) => {
10+
{
511
ReactDOMRe.createDOMElementVariadic("div", [{msg->React.string}])
612
}
13+
}
714
let make = {
8-
let \"CommentAtTop" = (\"Props": {"msg": 'msg}) => make(~msg=\"Props"["msg"])
15+
let \"CommentAtTop" = (props: props<_>) => make(props)
916
\"CommentAtTop"
1017
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
module Foo = {
2-
@obj
3-
external componentProps: (~a: int, ~b: string, ~key: string=?, unit) => {"a": int, "b": string} =
4-
""
2+
type props<'a, 'b> = {
3+
@optional key: string,
4+
@optional ref: React.ref<Js.Nullable.t<Dom.element>>,
5+
a: 'a,
6+
b: 'b,
7+
}
58
@module("Foo")
6-
external component: React.componentLike<{"a": int, "b": string}, React.element> = "component"
9+
external component: React.componentLike<props<'a, 'b>, React.element> = "component"
710
}
811

9-
let t = React.createElement(Foo.component, Foo.componentProps(~a=1, ~b={"1"}, ()))
12+
let t = React.createElement(Foo.component, {a: 1, b: "1"})
+26-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
module Bar = {
2-
@obj external makeProps: (~a: 'a, ~b: 'b, ~key: string=?, unit) => {"a": 'a, "b": 'b} = ""
3-
let make =
4-
(@warning("-16") ~a, @warning("-16") ~b, _) => {
5-
Js.log("This function should be named `InnerModule.react$Bar`")
6-
ReactDOMRe.createDOMElementVariadic("div", [])
7-
}
2+
type props<'a, 'b> = {
3+
@optional key: string,
4+
@optional ref: React.ref<Js.Nullable.t<Dom.element>>,
5+
a: 'a,
6+
b: 'b,
7+
}
8+
let make = ({a, b, ref}: props<'a, 'b>) => {
9+
let _ = ref
10+
11+
Js.log("This function should be named `InnerModule.react$Bar`")
12+
ReactDOMRe.createDOMElementVariadic("div", [])
13+
}
814
let make = {
9-
let \"InnerModule$Bar" = (\"Props": {"a": 'a, "b": 'b}) =>
10-
make(~b=\"Props"["b"], ~a=\"Props"["a"], ())
15+
let \"InnerModule$Bar" = (props: props<_>) => make(props)
1116
\"InnerModule$Bar"
1217
}
13-
@obj external componentProps: (~a: 'a, ~b: 'b, ~key: string=?, unit) => {"a": 'a, "b": 'b} = ""
18+
type props<'a, 'b> = {
19+
@optional key: string,
20+
@optional ref: React.ref<Js.Nullable.t<Dom.element>>,
21+
a: 'a,
22+
b: 'b,
23+
}
24+
25+
let component = ({a, b, ref}: props<'a, 'b>) => {
26+
let _ = ref
1427

15-
let component =
16-
(@warning("-16") ~a, @warning("-16") ~b, _) => {
17-
Js.log("This function should be named `InnerModule.react$Bar$component`")
18-
ReactDOMRe.createDOMElementVariadic("div", [])
19-
}
28+
Js.log("This function should be named `InnerModule.react$Bar$component`")
29+
ReactDOMRe.createDOMElementVariadic("div", [])
30+
}
2031
let component = {
21-
let \"InnerModule$Bar$component" = (\"Props": {"a": 'a, "b": 'b}) =>
22-
component(~b=\"Props"["b"], ~a=\"Props"["a"], ())
32+
let \"InnerModule$Bar$component" = (props: props<_>) => make(props)
2333
\"InnerModule$Bar$component"
2434
}
2535
}
+13-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
@obj
2-
external makeProps: (
3-
~a: '\"type-a",
4-
~b: array<option<[#Foo('\"type-a")]>>,
5-
~c: 'a,
6-
~key: string=?,
7-
unit,
8-
) => {"a": '\"type-a", "b": array<option<[#Foo('\"type-a")]>>, "c": 'a} = ""
9-
let make = (type a, ~a: a, ~b: array<option<[#Foo(a)]>>, ~c: 'a, _) =>
10-
ReactDOMRe.createDOMElementVariadic("div", [])
1+
type props<'a, 'b, 'c> = {
2+
@optional key: string,
3+
@optional ref: React.ref<Js.Nullable.t<Dom.element>>,
4+
a: 'a,
5+
b: 'b,
6+
c: 'c,
7+
}
8+
let make = ({ref}: props<'a, 'b, 'c>) => {
9+
let _ = ref
10+
(type a, ~a: a, ~b: array<option<[#Foo(a)]>>, ~c: 'a, _) =>
11+
ReactDOMRe.createDOMElementVariadic("div", [])
12+
}
1113
let make = {
12-
let \"Newtype" = (\"Props": {"a": '\"type-a", "b": array<option<[#Foo('\"type-a")]>>, "c": 'a}) =>
13-
make(~c=\"Props"["c"], ~b=\"Props"["b"], ~a=\"Props"["a"])
14+
let \"Newtype" = (props: props<_>) => make(props)
1415
\"Newtype"
1516
}
+13-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
@obj external makeProps: (~a: 'a, ~b: 'b, ~key: string=?, unit) => {"a": 'a, "b": 'b} = ""
2-
let make =
3-
(@warning("-16") ~a, @warning("-16") ~b, _) => {
4-
Js.log("This function should be named 'TopLevel.react'")
5-
ReactDOMRe.createDOMElementVariadic("div", [])
6-
}
1+
type props<'a, 'b> = {
2+
@optional key: string,
3+
@optional ref: React.ref<Js.Nullable.t<Dom.element>>,
4+
a: 'a,
5+
b: 'b,
6+
}
7+
let make = ({a, b, ref}: props<'a, 'b>) => {
8+
let _ = ref
9+
10+
Js.log("This function should be named 'TopLevel.react'")
11+
ReactDOMRe.createDOMElementVariadic("div", [])
12+
}
713
let make = {
8-
let \"TopLevel" = (\"Props": {"a": 'a, "b": 'b}) => make(~b=\"Props"["b"], ~a=\"Props"["a"], ())
14+
let \"TopLevel" = (props: props<_>) => make(props)
915
\"TopLevel"
1016
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
@obj external makeProps: (~a: 'a, ~b: 'b, ~key: string=?, unit) => {"a": 'a, "b": 'b} = ""
2-
let make:
3-
type a. (~a: a, ~b: a, a) => React.element =
4-
(~a, ~b, _) => ReactDOMRe.createDOMElementVariadic("div", [])
1+
type props<'a, 'b> = {
2+
@optional key: string,
3+
@optional ref: React.ref<Js.Nullable.t<Dom.element>>,
4+
a: 'a,
5+
b: 'b,
6+
}
7+
let make: 'a. (~a: 'a, ~b: 'a, 'a) => React.element = ({ref}: props<'a, 'b>) => {
8+
let _ = ref
9+
(type a): ((~a: a, ~b: a, a) => React.element) =>
10+
(~a, ~b, _) => ReactDOMRe.createDOMElementVariadic("div", [])
11+
}
512
let make = {
6-
let \"TypeConstraint" = (\"Props": {"a": 'a, "b": 'b}) => make(~b=\"Props"["b"], ~a=\"Props"["a"])
13+
let \"TypeConstraint" = (props: props<_>) => make(props)
714
\"TypeConstraint"
815
}

0 commit comments

Comments
 (0)