Skip to content

Commit 1f63b9e

Browse files
authored
fix(react-hook-form): update Controller component type definition (#13)
* fix(react-hook-form): update Controller component type definition - Make `name` parameter required instead of optional - Make `rules` parameter optional instead of required - Change labeled arguments to optional in type definitions * change log
1 parent a44ec37 commit 1f63b9e

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# v0.0.8 (unrelease)
22

33
- Add `useWatch` hook
4+
- Updated Controller component type definition in react-hook-form: made name parameter required and rules parameter optional
45

56
# v0.0.7
67

doc/transformation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ module ControllerOfInputs = {
8181
8282
@module("react-hook-form") @react.component
8383
external make: (
84-
~name: variantOfInputs=?,
84+
~name: variantOfInputs,
8585
~control: controlOfInputs=?,
86-
~rules: controllerRulesOfInputs,
86+
~rules: controllerRulesOfInputs=?,
8787
~render: controllerFieldsOfInputs => React.element=?,
8888
) => React.element = "Controller"
8989
}

src/ppx/signature.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,9 @@ let map_type_decl
539539
];
540540
(* @module("react-hook-form") @react.component
541541
external make: (
542-
~name: variantOfInputs=?,
542+
~name: variantOfInputs,
543543
~control: controlOfInputs=?,
544-
~rules: controllerRulesOfInputs,
544+
~rules: controllerRulesOfInputs=?,
545545
~render: controllerFieldsOfInputs => React.element=?,
546546
) => React.element = "Controller" *)
547547
Sig.value
@@ -564,17 +564,17 @@ let map_type_decl
564564
(Typ.constr ~attrs:[ attr_named_arg ]
565565
(lid @@ "variantOf" ^ capitalize record_name)
566566
[])
567-
(Typ.arrow (Labelled "control")
567+
(Typ.arrow (Optional "control")
568568
(Typ.constr ~attrs:[ attr_named_arg ]
569569
(lid @@ "controlOf"
570570
^ capitalize record_name)
571571
[])
572-
(Typ.arrow (Labelled "rules")
572+
(Typ.arrow (Optional "rules")
573573
(Typ.constr ~attrs:[ attr_named_arg ]
574574
(lid @@ "controllerRulesOf"
575575
^ capitalize record_name)
576576
[])
577-
(Typ.arrow (Labelled "render")
577+
(Typ.arrow (Optional "render")
578578
(uncurried_core_type_arrow
579579
~attrs:[ attr_named_arg ] ~arity:1
580580
[

src/ppx/structure.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,9 @@ let map_type_decl
538538
];
539539
(* @module("react-hook-form") @react.component
540540
external make: (
541-
~name: variantOfInputs=?,
541+
~name: variantOfInputs,
542542
~control: controlOfInputs=?,
543-
~rules: controllerRulesOfInputs,
543+
~rules: controllerRulesOfInputs=?,
544544
~render: controllerFieldsOfInputs => React.element=?,
545545
) => React.element = "Controller" *)
546546
Str.primitive
@@ -563,17 +563,17 @@ let map_type_decl
563563
(Typ.constr ~attrs:[ attr_named_arg ]
564564
(lid @@ "variantOf" ^ capitalize record_name)
565565
[])
566-
(Typ.arrow (Labelled "control")
566+
(Typ.arrow (Optional "control")
567567
(Typ.constr ~attrs:[ attr_named_arg ]
568568
(lid @@ "controlOf"
569569
^ capitalize record_name)
570570
[])
571-
(Typ.arrow (Labelled "rules")
571+
(Typ.arrow (Optional "rules")
572572
(Typ.constr ~attrs:[ attr_named_arg ]
573573
(lid @@ "controllerRulesOf"
574574
^ capitalize record_name)
575575
[])
576-
(Typ.arrow (Labelled "render")
576+
(Typ.arrow (Optional "render")
577577
(uncurried_core_type_arrow
578578
~attrs:[ attr_named_arg ] ~arity:1
579579
[

0 commit comments

Comments
 (0)