File tree Expand file tree Collapse file tree 3 files changed +85
-1
lines changed Expand file tree Collapse file tree 3 files changed +85
-1
lines changed Original file line number Diff line number Diff line change @@ -889,3 +889,47 @@ Object {
889
889
},
890
890
}
891
891
` ;
892
+
893
+ exports [` main fixtures processes component "component_17.js" without errors 1` ] = `
894
+ Object {
895
+ " description" : " " ,
896
+ " displayName" : " Foo" ,
897
+ " methods" : Array [],
898
+ " props" : Object {
899
+ " oneOfTypeProp" : Object {
900
+ " description" : " " ,
901
+ " required" : false ,
902
+ " type" : Object {
903
+ " name" : " union" ,
904
+ " value" : Array [
905
+ Object {
906
+ " description" : " Comment for type string" ,
907
+ " name" : " string" ,
908
+ },
909
+ Object {
910
+ " name" : " number" ,
911
+ },
912
+ ],
913
+ },
914
+ },
915
+ " shapeProp" : Object {
916
+ " description" : " " ,
917
+ " required" : false ,
918
+ " type" : Object {
919
+ " name" : " shape" ,
920
+ " value" : Object {
921
+ " a" : Object {
922
+ " description" : " Comment for property a" ,
923
+ " name" : " string" ,
924
+ " required" : false ,
925
+ },
926
+ " b" : Object {
927
+ " name" : " number" ,
928
+ " required" : false ,
929
+ },
930
+ },
931
+ },
932
+ },
933
+ },
934
+ }
935
+ ` ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2015, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ */
10
+
11
+ /**
12
+ * Testing descriptions of shape and oneOfType values
13
+ */
14
+
15
+ import React from 'react' ;
16
+ import PropTypes from 'prop-types' ;
17
+
18
+ export default function Foo ( props ) {
19
+ return < div /> ;
20
+ }
21
+
22
+ Foo . propTypes = {
23
+ shapeProp : PropTypes . shape ( {
24
+ /** Comment for property a */
25
+ a : PropTypes . string ,
26
+ b : PropTypes . number
27
+ } ) ,
28
+ oneOfTypeProp : PropTypes . oneOfType ( [
29
+ /** Comment for type string */
30
+ PropTypes . string ,
31
+ PropTypes . number
32
+ ] )
33
+ } ;
Original file line number Diff line number Diff line change @@ -80,7 +80,14 @@ function getPropTypeOneOfType(argumentPath) {
80
80
type . computed = true ;
81
81
type . value = printValue ( argumentPath ) ;
82
82
} else {
83
- type . value = argumentPath . get ( 'elements' ) . map ( getPropType ) ;
83
+ type . value = argumentPath . get ( 'elements' ) . map ( function ( itemPath ) {
84
+ const descriptor : PropTypeDescriptor = getPropType ( itemPath ) ;
85
+ const docs = getDocblock ( itemPath ) ;
86
+ if ( docs ) {
87
+ descriptor . description = docs ;
88
+ }
89
+ return descriptor ;
90
+ } ) ;
84
91
}
85
92
return type ;
86
93
}
You can’t perform that action at this time.
0 commit comments