This repository was archived by the owner on Jun 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -985,8 +985,20 @@ let transformComponentDefinition nestedModules mapper structure returnStructures
985
985
| Pexp_fun (arg_label , _default , {ppat_loc} , expr ) ->
986
986
if isLabelled arg_label || isOptional arg_label then
987
987
returnedExpression
988
- (( {loc = ppat_loc; txt = Lident (getLabel arg_label)},
989
- Pat. var {txt = getLabel arg_label; loc = ppat_loc} )
988
+ ((if isOptional arg_label then
989
+ (* { name: @optional name } *)
990
+ ( {loc = ppat_loc; txt = Lident (getLabel arg_label)},
991
+ Pat. constraint_
992
+ (Pat. var {txt = getLabel arg_label; loc = ppat_loc})
993
+ (Typ. constr ~attrs: optionalAttr
994
+ {
995
+ txt = Lident (getLabel arg_label);
996
+ loc = Location. none;
997
+ }
998
+ [] ) )
999
+ else
1000
+ ( {loc = ppat_loc; txt = Lident (getLabel arg_label)},
1001
+ Pat. var {txt = getLabel arg_label; loc = ppat_loc} ))
990
1002
:: patterns)
991
1003
expr
992
1004
else returnedExpression patterns expr
@@ -1005,7 +1017,7 @@ let transformComponentDefinition nestedModules mapper structure returnStructures
1005
1017
let pattern =
1006
1018
match patternsWithLid with
1007
1019
| [] -> Pat. any ()
1008
- | _ -> Pat. record patternsWithLid Closed
1020
+ | _ -> Pat. record patternsWithLid Open
1009
1021
in
1010
1022
(* add patttern matching for optional prop value *)
1011
1023
let expression =
You can’t perform that action at this time.
0 commit comments