@@ -277,7 +277,7 @@ let makePropsTypeParams ?(stripExplicitOption = false)
277
277
For example, if JSX ppx is used for React Native, type would be different.
278
278
*)
279
279
match interiorType with
280
- | {ptyp_desc = Ptyp_var "ref" } -> Some (refType loc)
280
+ | {ptyp_desc = Ptyp_any } -> Some (refType loc)
281
281
| _ ->
282
282
(* Strip explicit Js.Nullable.t in case of forwardRef *)
283
283
if stripExplicitJsNullableOfRef then stripJsNullable interiorType
@@ -687,46 +687,18 @@ let rec recursivelyTransformNamedArgsForMake mapper expr args newtypes coreType
687
687
(Some coreType)
688
688
| _ -> (args, newtypes, coreType)
689
689
690
- let newtypeToVar newtype type_ =
691
- let var_desc = Ptyp_var (" type-" ^ newtype) in
692
- let typ (mapper : Ast_mapper.mapper ) typ =
693
- match typ.ptyp_desc with
694
- | Ptyp_constr ({txt = Lident name } , _ ) when name = newtype ->
695
- {typ with ptyp_desc = var_desc}
696
- | _ -> Ast_mapper. default_mapper.typ mapper typ
697
- in
698
- let mapper = {Ast_mapper. default_mapper with typ} in
699
- mapper.typ mapper type_
700
-
701
- let argToType ~newtypes ~(typeConstraints : core_type option ) types
690
+ let argToType types
702
691
((name , default , {ppat_attributes = attrs } , _alias , loc , type_ ) :
703
692
arg_label * expression option * pattern * label * 'loc * core_type option )
704
693
=
705
- let rec getType name coreType =
706
- match coreType with
707
- | {ptyp_desc = Ptyp_arrow (arg , c1 , c2 )} ->
708
- if name = arg then Some c1 else getType name c2
709
- | _ -> None
710
- in
711
- let typeConst = Option. bind typeConstraints (getType name) in
712
- let type_ =
713
- List. fold_left
714
- (fun type_ newtype ->
715
- match (type_, typeConst) with
716
- | _ , Some typ | Some typ , None -> Some (newtypeToVar newtype.txt typ)
717
- | _ -> None )
718
- type_ newtypes
719
- in
720
694
match (type_, name, default) with
721
695
| Some type_ , name , _ when isOptional name ->
722
696
(true , getLabel name, attrs, loc, type_) :: types
723
697
| Some type_ , name , _ -> (false , getLabel name, attrs, loc, type_) :: types
724
698
| None , name , _ when isOptional name ->
725
- (true , getLabel name, attrs, loc, Typ. var ~loc (safeTypeFromValue name))
726
- :: types
699
+ (true , getLabel name, attrs, loc, Typ. any ~loc () ) :: types
727
700
| None , name , _ when isLabelled name ->
728
- (false , getLabel name, attrs, loc, Typ. var ~loc (safeTypeFromValue name))
729
- :: types
701
+ (false , getLabel name, attrs, loc, Typ. any ~loc () ) :: types
730
702
| _ -> types
731
703
732
704
let hasDefaultValue nameArgList =
@@ -1006,16 +978,12 @@ let transformStructureItem ~config mapper item =
1006
978
modifiedBinding binding
1007
979
in
1008
980
(* do stuff here! *)
1009
- let namedArgList, newtypes, typeConstraints =
981
+ let namedArgList, newtypes, _typeConstraints =
1010
982
recursivelyTransformNamedArgsForMake mapper
1011
983
(modifiedBindingOld binding)
1012
984
[] [] None
1013
985
in
1014
- let namedTypeList =
1015
- List. fold_left
1016
- (argToType ~newtypes ~type Constraints)
1017
- [] namedArgList
1018
- in
986
+ let namedTypeList = List. fold_left argToType [] namedArgList in
1019
987
let vbMatch (name , default , _ , alias , loc , _ ) =
1020
988
let label = getLabel name in
1021
989
match default with
@@ -1208,6 +1176,13 @@ let transformStructureItem ~config mapper item =
1208
1176
| _ -> [Typ. any () ]))))
1209
1177
expression
1210
1178
in
1179
+ let expression =
1180
+ (* Add new tupes (type a,b,c) to make's definition *)
1181
+ newtypes
1182
+ |> List. fold_left
1183
+ (fun e newtype -> Exp. newtype newtype e)
1184
+ expression
1185
+ in
1211
1186
(* let make = ({id, name, ...}: props<'id, 'name, ...>) => { ... } *)
1212
1187
let bindings, newBinding =
1213
1188
match recFlag with
0 commit comments