@@ -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 =
@@ -757,15 +761,19 @@ let transformStructureItem ~config mapper item =
757
761
|> Option. map React_jsx_common. typVarsOfCoreType
758
762
|> Option. value ~default: []
759
763
in
760
- let rec getPropTypes types ({ptyp_loc; ptyp_desc} as fullType ) =
764
+ let rec getPropTypes types
765
+ ({ptyp_loc; ptyp_desc; ptyp_attributes} as fullType ) =
761
766
match ptyp_desc with
762
767
| Ptyp_arrow (name, type_, ({ptyp_desc = Ptyp_arrow _} as rest))
763
768
when isLabelled name || isOptional name ->
764
- getPropTypes ((name, ptyp_loc, type_) :: types) rest
769
+ getPropTypes
770
+ ((name, ptyp_attributes, ptyp_loc, type_) :: types)
771
+ rest
765
772
| Ptyp_arrow (Nolabel, _type , rest ) -> getPropTypes types rest
766
773
| Ptyp_arrow (name, type_, returnValue)
767
774
when isLabelled name || isOptional name ->
768
- (returnValue, (name, returnValue.ptyp_loc, type_) :: types)
775
+ ( returnValue,
776
+ (name, ptyp_attributes, returnValue.ptyp_loc, type_) :: types )
769
777
| _ -> (fullType, types)
770
778
in
771
779
let innerType, propTypes = getPropTypes [] pval_type in
@@ -1237,19 +1245,22 @@ let transformSignatureItem ~config _mapper item =
1237
1245
in
1238
1246
let rec getPropTypes types ({ptyp_loc; ptyp_desc} as fullType ) =
1239
1247
match ptyp_desc with
1240
- | Ptyp_arrow (name, type_, ({ptyp_desc = Ptyp_arrow _} as rest))
1248
+ | Ptyp_arrow
1249
+ ( name,
1250
+ ({ptyp_attributes = attrs} as type_),
1251
+ ({ptyp_desc = Ptyp_arrow _} as rest) )
1241
1252
when isOptional name || isLabelled name ->
1242
- getPropTypes ((name, ptyp_loc, type_) :: types) rest
1253
+ getPropTypes ((name, attrs, ptyp_loc, type_) :: types) rest
1243
1254
| Ptyp_arrow
1244
1255
(Nolabel , {ptyp_desc = Ptyp_constr ({txt = Lident " unit" }, _)}, rest)
1245
1256
->
1246
1257
getPropTypes types rest
1247
1258
| Ptyp_arrow (Nolabel, _type , rest ) ->
1248
1259
hasForwardRef := true ;
1249
1260
getPropTypes types rest
1250
- | Ptyp_arrow (name, type_, returnValue)
1261
+ | Ptyp_arrow (name, ({ptyp_attributes = attrs} as type_) , returnValue)
1251
1262
when isOptional name || isLabelled name ->
1252
- (returnValue, (name, returnValue.ptyp_loc, type_) :: types)
1263
+ (returnValue, (name, attrs, returnValue.ptyp_loc, type_) :: types)
1253
1264
| _ -> (fullType, types)
1254
1265
in
1255
1266
let innerType, propTypes = getPropTypes [] pval_type in
0 commit comments