@@ -274995,7 +274995,7 @@ let makePropsTypeParams ?(stripExplicitOption = false)
274995274995 For example, if JSX ppx is used for React Native, type would be different.
274996274996 *)
274997274997 match interiorType with
274998- | {ptyp_desc = Ptyp_var "ref" } -> Some (refType loc)
274998+ | {ptyp_desc = Ptyp_any } -> Some (refType loc)
274999274999 | _ ->
275000275000 (* Strip explicit Js.Nullable.t in case of forwardRef *)
275001275001 if stripExplicitJsNullableOfRef then stripJsNullable interiorType
@@ -275405,46 +275405,18 @@ let rec recursivelyTransformNamedArgsForMake mapper expr args newtypes coreType
275405275405 (Some coreType)
275406275406 | _ -> (args, newtypes, coreType)
275407275407
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
275420275409 ((name, default, {ppat_attributes = attrs}, _alias, loc, type_) :
275421275410 arg_label * expression option * pattern * label * 'loc * core_type option)
275422275411 =
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
275438275412 match (type_, name, default) with
275439275413 | Some type_, name, _ when isOptional name ->
275440275414 (true, getLabel name, attrs, loc, type_) :: types
275441275415 | Some type_, name, _ -> (false, getLabel name, attrs, loc, type_) :: types
275442275416 | 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
275445275418 | 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
275448275420 | _ -> types
275449275421
275450275422let hasDefaultValue nameArgList =
@@ -275724,16 +275696,12 @@ let transformStructureItem ~config mapper item =
275724275696 modifiedBinding binding
275725275697 in
275726275698 (* do stuff here! *)
275727- let namedArgList, newtypes, typeConstraints =
275699+ let namedArgList, newtypes, _typeConstraints =
275728275700 recursivelyTransformNamedArgsForMake mapper
275729275701 (modifiedBindingOld binding)
275730275702 [] [] None
275731275703 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
275737275705 let vbMatch (name, default, _, alias, loc, _) =
275738275706 let label = getLabel name in
275739275707 match default with
@@ -275926,6 +275894,13 @@ let transformStructureItem ~config mapper item =
275926275894 | _ -> [Typ.any ()]))))
275927275895 expression
275928275896 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
275929275904 (* let make = ({id, name, ...}: props<'id, 'name, ...>) => { ... } *)
275930275905 let bindings, newBinding =
275931275906 match recFlag with
0 commit comments