@@ -274995,7 +274995,7 @@ let makePropsTypeParams ?(stripExplicitOption = false)
274995
274995
For example, if JSX ppx is used for React Native, type would be different.
274996
274996
*)
274997
274997
match interiorType with
274998
- | {ptyp_desc = Ptyp_var "ref" } -> Some (refType loc)
274998
+ | {ptyp_desc = Ptyp_any } -> Some (refType loc)
274999
274999
| _ ->
275000
275000
(* Strip explicit Js.Nullable.t in case of forwardRef *)
275001
275001
if stripExplicitJsNullableOfRef then stripJsNullable interiorType
@@ -275405,46 +275405,18 @@ let rec recursivelyTransformNamedArgsForMake mapper expr args newtypes coreType
275405
275405
(Some coreType)
275406
275406
| _ -> (args, newtypes, coreType)
275407
275407
275408
- let newtypeToVar newtype type_ =
275409
- let var_desc = Ptyp_var ("type-" ^ newtype) in
275410
- let typ (mapper : Ast_mapper.mapper) typ =
275411
- match typ.ptyp_desc with
275412
- | Ptyp_constr ({txt = Lident name}, _) when name = newtype ->
275413
- {typ with ptyp_desc = var_desc}
275414
- | _ -> Ast_mapper.default_mapper.typ mapper typ
275415
- in
275416
- let mapper = {Ast_mapper.default_mapper with typ} in
275417
- mapper.typ mapper type_
275418
-
275419
- let argToType ~newtypes ~(typeConstraints : core_type option) types
275408
+ let argToType types
275420
275409
((name, default, {ppat_attributes = attrs}, _alias, loc, type_) :
275421
275410
arg_label * expression option * pattern * label * 'loc * core_type option)
275422
275411
=
275423
- let rec getType name coreType =
275424
- match coreType with
275425
- | {ptyp_desc = Ptyp_arrow (arg, c1, c2)} ->
275426
- if name = arg then Some c1 else getType name c2
275427
- | _ -> None
275428
- in
275429
- let typeConst = Option.bind typeConstraints (getType name) in
275430
- let type_ =
275431
- List.fold_left
275432
- (fun type_ newtype ->
275433
- match (type_, typeConst) with
275434
- | _, Some typ | Some typ, None -> Some (newtypeToVar newtype.txt typ)
275435
- | _ -> None)
275436
- type_ newtypes
275437
- in
275438
275412
match (type_, name, default) with
275439
275413
| Some type_, name, _ when isOptional name ->
275440
275414
(true, getLabel name, attrs, loc, type_) :: types
275441
275415
| Some type_, name, _ -> (false, getLabel name, attrs, loc, type_) :: types
275442
275416
| None, name, _ when isOptional name ->
275443
- (true, getLabel name, attrs, loc, Typ.var ~loc (safeTypeFromValue name))
275444
- :: types
275417
+ (true, getLabel name, attrs, loc, Typ.any ~loc ()) :: types
275445
275418
| None, name, _ when isLabelled name ->
275446
- (false, getLabel name, attrs, loc, Typ.var ~loc (safeTypeFromValue name))
275447
- :: types
275419
+ (false, getLabel name, attrs, loc, Typ.any ~loc ()) :: types
275448
275420
| _ -> types
275449
275421
275450
275422
let hasDefaultValue nameArgList =
@@ -275724,16 +275696,12 @@ let transformStructureItem ~config mapper item =
275724
275696
modifiedBinding binding
275725
275697
in
275726
275698
(* do stuff here! *)
275727
- let namedArgList, newtypes, typeConstraints =
275699
+ let namedArgList, newtypes, _typeConstraints =
275728
275700
recursivelyTransformNamedArgsForMake mapper
275729
275701
(modifiedBindingOld binding)
275730
275702
[] [] None
275731
275703
in
275732
- let namedTypeList =
275733
- List.fold_left
275734
- (argToType ~newtypes ~typeConstraints)
275735
- [] namedArgList
275736
- in
275704
+ let namedTypeList = List.fold_left argToType [] namedArgList in
275737
275705
let vbMatch (name, default, _, alias, loc, _) =
275738
275706
let label = getLabel name in
275739
275707
match default with
@@ -275926,6 +275894,13 @@ let transformStructureItem ~config mapper item =
275926
275894
| _ -> [Typ.any ()]))))
275927
275895
expression
275928
275896
in
275897
+ let expression =
275898
+ (* Add new tupes (type a,b,c) to make's definition *)
275899
+ newtypes
275900
+ |> List.fold_left
275901
+ (fun e newtype -> Exp.newtype newtype e)
275902
+ expression
275903
+ in
275929
275904
(* let make = ({id, name, ...}: props<'id, 'name, ...>) => { ... } *)
275930
275905
let bindings, newBinding =
275931
275906
match recFlag with
0 commit comments