File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,6 @@ describe('getPropType', () => {
85
85
value : [ { name : 'custom' , raw : 'foo' } ] ,
86
86
} ) ;
87
87
88
- // custom type
89
88
expect ( getPropType ( expression ( 'instanceOf(Foo)' ) ) ) . toEqual ( {
90
89
name : 'instanceOf' ,
91
90
value : 'Foo' ,
@@ -96,6 +95,11 @@ describe('getPropType', () => {
96
95
value : { name : 'string' } ,
97
96
} ) ;
98
97
98
+ expect ( getPropType ( expression ( 'objectOf(string)' ) ) ) . toEqual ( {
99
+ name : 'objectOf' ,
100
+ value : { name : 'string' } ,
101
+ } ) ;
102
+
99
103
expect ( getPropType ( expression ( 'shape({foo: string, bar: bool})' ) ) ) . toEqual ( {
100
104
name : 'shape' ,
101
105
value : {
Original file line number Diff line number Diff line change @@ -67,6 +67,19 @@ function getPropTypeArrayOf(argumentPath) {
67
67
return type ;
68
68
}
69
69
70
+ function getPropTypeObjectOf ( argumentPath ) {
71
+ var type : PropTypeDescriptor = { name : 'objectOf' } ;
72
+ var subType = getPropType ( argumentPath ) ;
73
+
74
+ if ( subType . name === 'unknown' ) {
75
+ type . value = printValue ( argumentPath ) ;
76
+ type . computed = true ;
77
+ } else {
78
+ type . value = subType ;
79
+ }
80
+ return type ;
81
+ }
82
+
70
83
function getPropTypeShape ( argumentPath ) {
71
84
var type : PropTypeDescriptor = { name : 'shape' , value : 'unknown' } ;
72
85
if ( ! types . ObjectExpression . check ( argumentPath . node ) ) {
@@ -116,6 +129,7 @@ var propTypes = {
116
129
oneOfType : getPropTypeOneOfType ,
117
130
instanceOf : getPropTypeInstanceOf ,
118
131
arrayOf : getPropTypeArrayOf ,
132
+ objectOf : getPropTypeObjectOf ,
119
133
shape : getPropTypeShape ,
120
134
} ;
121
135
You can’t perform that action at this time.
0 commit comments