@@ -289,14 +289,15 @@ let makePropsTypeParams ?(stripExplicitOption = false)
289
289
290
290
let makeLabelDecls ~loc namedTypeList =
291
291
namedTypeList
292
- |> List. map (fun (isOptional , label , _ , interiorType ) ->
292
+ |> List. map (fun (isOptional , label , attrs , interiorType ) ->
293
293
if label = " key" then
294
- Type. field ~loc ~attrs: optionalAttrs {txt = label; loc} interiorType
294
+ Type. field ~loc ~attrs: (optionalAttrs @ attrs) {txt = label; loc}
295
+ interiorType
295
296
else if isOptional then
296
- Type. field ~loc ~attrs: optionalAttrs {txt = label; loc}
297
+ Type. field ~loc ~attrs: ( optionalAttrs @ attrs) {txt = label; loc}
297
298
(Typ. var @@ safeTypeFromValue @@ Labelled label)
298
299
else
299
- Type. field ~loc {txt = label; loc}
300
+ Type. field ~loc ~attrs {txt = label; loc}
300
301
(Typ. var @@ safeTypeFromValue @@ Labelled label))
301
302
302
303
let makeTypeDecls propsName loc namedTypeList =
@@ -681,7 +682,9 @@ let newtypeToVar newtype type_ =
681
682
mapper.typ mapper type_
682
683
683
684
let argToType ~newtypes ~(typeConstraints : core_type option ) types
684
- (name , default , _noLabelName , _alias , loc , type_ ) =
685
+ ((name , default , {ppat_attributes = attrs } , _alias , loc , type_ ) :
686
+ arg_label * expression option * pattern * label * 'loc * core_type option )
687
+ =
685
688
let rec getType name coreType =
686
689
match coreType with
687
690
| {ptyp_desc = Ptyp_arrow (arg , c1 , c2 )} ->
@@ -699,28 +702,29 @@ let argToType ~newtypes ~(typeConstraints : core_type option) types
699
702
in
700
703
match (type_, name, default) with
701
704
| Some type_ , name , _ when isOptional name ->
702
- (true , getLabel name, [] , {type_ with ptyp_attributes = optionalAttrs})
705
+ (true , getLabel name, attrs , {type_ with ptyp_attributes = optionalAttrs})
703
706
:: types
704
- | Some type_ , name , _ -> (false , getLabel name, [] , type_) :: types
707
+ | Some type_ , name , _ -> (false , getLabel name, attrs , type_) :: types
705
708
| None , name , _ when isOptional name ->
706
709
( true ,
707
710
getLabel name,
708
- [] ,
711
+ attrs ,
709
712
Typ. var ~loc ~attrs: optionalAttrs (safeTypeFromValue name) )
710
713
:: types
711
714
| None , name , _ when isLabelled name ->
712
- (false , getLabel name, [] , Typ. var ~loc (safeTypeFromValue name)) :: types
715
+ (false , getLabel name, attrs, Typ. var ~loc (safeTypeFromValue name))
716
+ :: types
713
717
| _ -> types
714
718
715
719
let argWithDefaultValue (name , default , _ , _ , _ , _ ) =
716
720
match default with
717
721
| Some default when isOptional name -> Some (getLabel name, default)
718
722
| _ -> None
719
723
720
- let argToConcreteType types (name , _loc , type_ ) =
724
+ let argToConcreteType types (name , attrs , _loc , type_ ) =
721
725
match name with
722
- | name when isLabelled name -> (false , getLabel name, [] , type_) :: types
723
- | name when isOptional name -> (true , getLabel name, [] , type_) :: types
726
+ | name when isLabelled name -> (false , getLabel name, attrs , type_) :: types
727
+ | name when isOptional name -> (true , getLabel name, attrs , type_) :: types
724
728
| _ -> types
725
729
726
730
let check_string_int_attribute_iter =
@@ -763,15 +767,19 @@ let transformStructureItem ~config mapper item =
763
767
|> Option. map React_jsx_common. typVarsOfCoreType
764
768
|> Option. value ~default: []
765
769
in
766
- let rec getPropTypes types ({ptyp_loc; ptyp_desc} as fullType ) =
770
+ let rec getPropTypes types
771
+ ({ptyp_loc; ptyp_desc; ptyp_attributes} as fullType ) =
767
772
match ptyp_desc with
768
773
| Ptyp_arrow (name, type_, ({ptyp_desc = Ptyp_arrow _} as rest))
769
774
when isLabelled name || isOptional name ->
770
- getPropTypes ((name, ptyp_loc, type_) :: types) rest
775
+ getPropTypes
776
+ ((name, ptyp_attributes, ptyp_loc, type_) :: types)
777
+ rest
771
778
| Ptyp_arrow (Nolabel, _type , rest ) -> getPropTypes types rest
772
779
| Ptyp_arrow (name, type_, returnValue)
773
780
when isLabelled name || isOptional name ->
774
- (returnValue, (name, returnValue.ptyp_loc, type_) :: types)
781
+ ( returnValue,
782
+ (name, ptyp_attributes, returnValue.ptyp_loc, type_) :: types )
775
783
| _ -> (fullType, types)
776
784
in
777
785
let innerType, propTypes = getPropTypes [] pval_type in
@@ -1264,19 +1272,22 @@ let transformSignatureItem ~config _mapper item =
1264
1272
in
1265
1273
let rec getPropTypes types ({ptyp_loc; ptyp_desc} as fullType ) =
1266
1274
match ptyp_desc with
1267
- | Ptyp_arrow (name, type_, ({ptyp_desc = Ptyp_arrow _} as rest))
1275
+ | Ptyp_arrow
1276
+ ( name,
1277
+ ({ptyp_attributes = attrs} as type_),
1278
+ ({ptyp_desc = Ptyp_arrow _} as rest) )
1268
1279
when isOptional name || isLabelled name ->
1269
- getPropTypes ((name, ptyp_loc, type_) :: types) rest
1280
+ getPropTypes ((name, attrs, ptyp_loc, type_) :: types) rest
1270
1281
| Ptyp_arrow
1271
1282
(Nolabel , {ptyp_desc = Ptyp_constr ({txt = Lident " unit" }, _)}, rest)
1272
1283
->
1273
1284
getPropTypes types rest
1274
1285
| Ptyp_arrow (Nolabel, _type , rest ) ->
1275
1286
hasForwardRef := true ;
1276
1287
getPropTypes types rest
1277
- | Ptyp_arrow (name, type_, returnValue)
1288
+ | Ptyp_arrow (name, ({ptyp_attributes = attrs} as type_) , returnValue)
1278
1289
when isOptional name || isLabelled name ->
1279
- (returnValue, (name, returnValue.ptyp_loc, type_) :: types)
1290
+ (returnValue, (name, attrs, returnValue.ptyp_loc, type_) :: types)
1280
1291
| _ -> (fullType, types)
1281
1292
in
1282
1293
let innerType, propTypes = getPropTypes [] pval_type in
0 commit comments