File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -145,4 +145,30 @@ describe('getPropType', () => {
145145 } ) ;
146146 } ) ;
147147
148+ it ( 'detects descriptions on nested types in shapes' , ( ) => {
149+ expect ( getPropType ( expression ( `shape({
150+ /**
151+ * test1
152+ */
153+ foo: string,
154+ /**
155+ * test2
156+ */
157+ bar: bool
158+ })` ) ) )
159+ . toEqual ( {
160+ name : 'shape' ,
161+ value : {
162+ foo : {
163+ name : 'string' ,
164+ description : 'test1' ,
165+ } ,
166+ bar : {
167+ name : 'bool' ,
168+ description : 'test2' ,
169+ } ,
170+ } ,
171+ } ) ;
172+ } ) ;
173+
148174} ) ;
Original file line number Diff line number Diff line change 1313/*eslint no-use-before-define: 0*/
1414
1515
16+ import { getDocblock } from '../utils/docblock' ;
1617import getMembers from './getMembers' ;
1718import getPropertyName from './getPropertyName' ;
1819import printValue from './printValue' ;
@@ -74,8 +75,12 @@ function getPropTypeShape(argumentPath) {
7475 if ( types . ObjectExpression . check ( argumentPath . node ) ) {
7576 type . value = { } ;
7677 argumentPath . get ( 'properties' ) . each ( function ( propertyPath ) {
77- type . value [ getPropertyName ( propertyPath ) ] =
78- getPropType ( propertyPath . get ( 'value' ) ) ;
78+ var descriptor = getPropType ( propertyPath . get ( 'value' ) , true ) ;
79+ var docs = getDocblock ( propertyPath ) ;
80+ if ( docs ) {
81+ descriptor . description = docs ;
82+ }
83+ type . value [ getPropertyName ( propertyPath ) ] = descriptor ;
7984 } ) ;
8085 }
8186
You can’t perform that action at this time.
0 commit comments