1515
1616var getMembers = require ( './getMembers' ) ;
1717var getPropertyName = require ( './getPropertyName' ) ;
18+ var printValue = require ( './printValue' ) ;
1819var recast = require ( 'recast' ) ;
1920var resolveToValue = require ( './resolveToValue' ) ;
2021
@@ -23,7 +24,7 @@ var types = recast.types.namedTypes;
2324function getEnumValues ( path ) {
2425 return path . get ( 'elements' ) . map ( function ( elementPath ) {
2526 return {
26- value : recast . print ( elementPath ) . code ,
27+ value : printValue ( elementPath ) ,
2728 computed : ! types . Literal . check ( elementPath . node )
2829 } ;
2930 } ) ;
@@ -33,7 +34,7 @@ function getPropTypeOneOf(argumentPath) {
3334 var type = { name : 'enum' } ;
3435 if ( ! types . ArrayExpression . check ( argumentPath . node ) ) {
3536 type . computed = true ;
36- type . value = recast . print ( argumentPath ) . code ;
37+ type . value = printValue ( argumentPath ) ;
3738 } else {
3839 type . value = getEnumValues ( argumentPath ) ;
3940 }
@@ -44,7 +45,7 @@ function getPropTypeOneOfType(argumentPath) {
4445 var type = { name : 'union' } ;
4546 if ( ! types . ArrayExpression . check ( argumentPath . node ) ) {
4647 type . computed = true ;
47- type . value = recast . print ( argumentPath ) . code ;
48+ type . value = printValue ( argumentPath ) ;
4849 } else {
4950 type . value = argumentPath . get ( 'elements' ) . map ( getPropType ) ;
5051 }
@@ -56,7 +57,7 @@ function getPropTypeArrayOf(argumentPath) {
5657 var subType = getPropType ( argumentPath ) ;
5758
5859 if ( subType . name === 'unknown' ) {
59- type . value = recast . print ( argumentPath ) . code ;
60+ type . value = printValue ( argumentPath ) ;
6061 type . computed = true ;
6162 } else {
6263 type . value = subType ;
@@ -84,7 +85,7 @@ function getPropTypeShape(argumentPath) {
8485function getPropTypeInstanceOf ( argumentPath ) {
8586 return {
8687 name : 'instanceOf' ,
87- value : recast . print ( argumentPath ) . code
88+ value : printValue ( argumentPath )
8889 } ;
8990}
9091
@@ -144,7 +145,7 @@ function getPropType(path: NodePath): PropTypeDescriptor {
144145 propTypes . hasOwnProperty ( node . callee . name ) ) {
145146 descriptor = propTypes [ node . callee . name ] ( path . get ( 'arguments' , 0 ) ) ;
146147 } else {
147- descriptor = { name : 'custom' , raw : recast . print ( path ) . code } ;
148+ descriptor = { name : 'custom' , raw : printValue ( path ) } ;
148149 }
149150 }
150151 return descriptor ;
0 commit comments