-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathJsx2.res
174 lines (129 loc) · 2.76 KB
/
Jsx2.res
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
module M = {
@react.component
let make = (~first, ~fun="", ~second="") => React.string(first ++ fun ++ second)
}
let _ = <M first="abc" />
// ^def
// <M second=fi
// ^com
// <M second="abc" f
// ^com
// let e = <M
// ^com
@react.component
let make = (~first) => React.string(first)
let y = 44
// <M prop={A(3)} k
// ^com
// <M prop=A(3) k
// ^com
// <M prop=foo(1+2) k
// ^com
// <M prop=list{1,2,3} k
// ^com
// <M prop=<N /> k
// ^com
// <M prop=1.5 k
// ^com
// <M prop=0X33 k
// ^com
// <M prop=12e+3 k
// ^com
// <M prop='z' k
// ^com
// <M prop=`before${foo}` k
// ^com
// <M prop=module(@foo Three: X_int) k
// ^com
// <M prop=%bs.raw("1") k
// ^com
let _ = <Component />
// ^def
module Ext = {
@react.component @module("@material-ui/core")
external make: (~align: string=?) => React.element = "Typography"
}
let _ = Ext.make
// <Ext al
// ^com
// <M first
// ^com
// <M first=#a k
// ^com
// <M first = ? #a k
// ^com
// <M>
// ^com
module WithChildren = {
@react.component
let make = (~name as _: string, ~children) => <jsx> children </jsx>
}
let _ = <WithChildren name=""> <div /> </WithChildren>
// <WithChildren
// ^com
// <WithChildren n
// ^com
// let c : React.e
// ^com
// let c : ReactDOMR
// ^com
module DefineSomeFields = {
type r = {thisField: int, thatField: string}
let thisValue = 10
// let foo x = x.th
// ^com
}
// let q = DefineSomeFields.
// ^com
// let foo x = x.DefineSomeFields.th
// ^com
let _ = x => x.DefineSomeFields.thisField + DefineSomeFields.thisValue
module Outer = {
module Inner = {
let hello = 3
}
}
let _ = Outer.Inner.hello
let _ =
<div
// x=Outer.Inner.h
// ^com
name=""
/>
let _ =
<div
// x=Outer.Inner.
// ^com
name=""
/>
let _ =
<div
// x=
// ^com
name=""
/>
module Nested = {
module Comp = {
@react.component
let make = (~name) => React.string(name)
}
}
let _ = <Nested.Comp name="" />
// let _ = <Nested.Co name="" />
// ^com
// let _ = <Nested. name="" />
// ^com
module Comp = {
@react.component
let make = (~age) => React.int(age)
}
let _ = {
<> <Comp age=34 /> </>
// ^hov
}
let _ = {
<> {<> <Comp age=34 /> </>} </>
// ^hov
}
module type ExtT = module type of Ext
let _ = module(Ext: ExtT)