Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit cc39cf5

Browse files
committed
remove uneccessary adding @optional attr from extracting props type
1 parent 51c3fee commit cc39cf5

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

cli/reactjs_jsx_ppx_v3.ml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,6 @@ let makePropsTypeParamsTvar namedTypeList =
258258
if label = "key" || label = "ref" then None
259259
else Some (Typ.var label, Invariant))
260260

261-
let extractOptionalCoreType = function
262-
| {ptyp_desc = Ptyp_constr ({txt}, [coreType])} when txt = optionIdent ->
263-
coreType
264-
| t -> t
265-
266261
(* make type params for make fn arguments *)
267262
(* let make = ({id, name, children}: props<'id, 'name, 'children>) *)
268263
let makePropsTypeParams namedTypeList =
@@ -274,10 +269,8 @@ let makePropsTypeParams namedTypeList =
274269
(* let make: React.componentLike<props<string, option<string>>, React.element> *)
275270
let makePropsTypeParamsSig namedTypeList =
276271
namedTypeList
277-
|> List.filter_map (fun (isOptional, label, _, interiorType) ->
278-
if label = "key" || label = "ref" then None
279-
else if isOptional then Some (extractOptionalCoreType interiorType)
280-
else Some interiorType)
272+
|> List.filter_map (fun (_isOptional, label, _, interiorType) ->
273+
if label = "key" || label = "ref" then None else Some interiorType)
281274

282275
(* type props<'id, 'name, ...> = { @optional key: string, @optional id: 'id, ... } *)
283276
let makePropsRecordType propsName loc namedTypeList =
@@ -604,12 +597,10 @@ let jsxMapper () =
604597
[@@raises Invalid_argument]
605598
in
606599

607-
let argToConcreteType types (name, loc, type_) =
600+
let argToConcreteType types (name, _loc, type_) =
608601
match name with
609602
| name when isLabelled name -> (false, getLabel name, [], type_) :: types
610-
| name when isOptional name ->
611-
(true, getLabel name, [], Typ.constr ~loc {loc; txt = optionIdent} [type_])
612-
:: types
603+
| name when isOptional name -> (true, getLabel name, [], type_) :: types
613604
| _ -> types
614605
in
615606

0 commit comments

Comments
 (0)