@@ -80,18 +80,60 @@ let map_type_decl
8080 (mknoloc " message" )
8181 (Typ. constr (lid " string" ) [] );
8282 ]);
83- (* @unboxed type watchReturnOfInputs = String(string) | Number(float) *)
83+ (* @unboxed
84+ type rec watchReturnOfInputs =
85+ | @as(null) Null
86+ | Bool(bool)
87+ | Number(float)
88+ | String(string)
89+ | Object(Js.Dict.t<watchReturnOfInputs>)
90+ | Array(array<watchReturnOfInputs>)
91+ *)
8492 Type. mk
8593 (mkloc (" watchReturnOf" ^ capitalize record_name) ptype_loc)
8694 ~attrs: [ Attr. mk (mknoloc " unboxed" ) (PStr [] ) ]
8795 ~priv: Public
8896 ~kind:
8997 (Ptype_variant
9098 [
91- Type. constructor (mknoloc " String" )
92- ~args: (Pcstr_tuple [ Typ. constr (lid " string" ) [] ]);
99+ Type. constructor (mknoloc " Null" )
100+ ~attrs:
101+ [
102+ Attr. mk (mknoloc " as" )
103+ (PStr [ Str. eval @@ Exp. ident (lid " null" ) ]);
104+ ];
105+ Type. constructor (mknoloc " Bool" )
106+ ~args: (Pcstr_tuple [ Typ. constr (lid " bool" ) [] ]);
93107 Type. constructor (mknoloc " Number" )
94108 ~args: (Pcstr_tuple [ Typ. constr (lid " float" ) [] ]);
109+ Type. constructor (mknoloc " String" )
110+ ~args: (Pcstr_tuple [ Typ. constr (lid " string" ) [] ]);
111+ Type. constructor (mknoloc " Object" )
112+ ~args:
113+ (Pcstr_tuple
114+ [
115+ Typ. constr (lid " Js.Dict.t" )
116+ [
117+ Typ. constr
118+ (lid
119+ (" watchReturnOf"
120+ ^ capitalize record_name))
121+ [];
122+ ];
123+ ]);
124+ Type. constructor (mknoloc " Array" )
125+ ~args:
126+ (Pcstr_tuple
127+ [
128+ Typ. constr (lid " array" )
129+ [
130+ Typ. constr
131+ (lid
132+ (" watchReturnOf"
133+ ^ capitalize record_name))
134+ [];
135+ ];
136+ ]);
95137 ]);
96138 ]
97139 in
@@ -161,18 +203,21 @@ let map_type_decl
161203 (Typ. constr (lid " unit" ) [] );
162204 ]);
163205 ]);
164- (* watch: variantOfInputs => watchReturnOfInputs, *)
206+ (* watch: variantOfInputs => option< watchReturnOfInputs> , *)
165207 Type. field ~mut: Immutable (mknoloc " watch" )
166208 (uncurried_core_type_arrow ~arity: 1
167209 [
168210 Typ. arrow Nolabel
169211 (Typ. constr
170212 (lid @@ " variantOf" ^ capitalize record_name)
171213 [] )
172- (Typ. constr
173- (lid @@ " watchReturnOf"
174- ^ capitalize record_name)
175- [] );
214+ (Typ. constr (lid " option" )
215+ [
216+ Typ. constr
217+ (lid @@ " watchReturnOf"
218+ ^ capitalize record_name)
219+ [];
220+ ]);
176221 ]);
177222 (* reset: (~options: defaultValuesOfInputs=?) => unit, *)
178223 Type. field ~mut: Immutable (mknoloc " reset" )
@@ -797,8 +842,8 @@ let map_type_decl
797842 (
798843 Typ
799844 .constr
800- (
801- lid
845+
846+ ( lid
802847 " string" )
803848 [] )
804849 );
@@ -822,8 +867,9 @@ let map_type_decl
822867 ~attrs:
823868 [
824869 Attr. mk
825- (mknoloc
826- " res.uapp" )
870+
871+ (mknoloc
872+ " res.uapp" )
827873 (PStr
828874 [] );
829875 ]
0 commit comments