@@ -186,15 +186,15 @@ const simplePropTypes = [
186
186
'elementType' ,
187
187
] ;
188
188
189
- const propTypes = {
190
- oneOf : getPropTypeOneOf ,
191
- oneOfType : getPropTypeOneOfType ,
192
- instanceOf : getPropTypeInstanceOf ,
193
- arrayOf : getPropTypeArrayOf ,
194
- objectOf : getPropTypeObjectOf ,
195
- shape : getPropTypeShapish . bind ( null , 'shape' ) ,
196
- exact : getPropTypeShapish . bind ( null , 'exact' ) ,
197
- } ;
189
+ const propTypes = new Map ( [
190
+ [ ' oneOf' , getPropTypeOneOf ] ,
191
+ [ ' oneOfType' , getPropTypeOneOfType ] ,
192
+ [ ' instanceOf' , getPropTypeInstanceOf ] ,
193
+ [ ' arrayOf' , getPropTypeArrayOf ] ,
194
+ [ ' objectOf' , getPropTypeObjectOf ] ,
195
+ [ ' shape' , getPropTypeShapish . bind ( null , 'shape' ) ] ,
196
+ [ ' exact' , getPropTypeShapish . bind ( null , 'exact' ) ] ,
197
+ ] ) ;
198
198
199
199
/**
200
200
* Tries to identify the prop type by inspecting the path for known
@@ -218,8 +218,8 @@ export default function getPropType(path: NodePath): PropTypeDescriptor {
218
218
if ( simplePropTypes . includes ( name ) ) {
219
219
descriptor = { name } ;
220
220
return true ;
221
- } else if ( propTypes . hasOwnProperty ( name ) && member . argumentsPath ) {
222
- descriptor = propTypes [ name ] ( member . argumentsPath . get ( 0 ) ) ;
221
+ } else if ( propTypes . has ( name ) && member . argumentsPath ) {
222
+ descriptor = propTypes . get ( name ) ( member . argumentsPath . get ( 0 ) ) ;
223
223
return true ;
224
224
}
225
225
}
@@ -231,9 +231,9 @@ export default function getPropType(path: NodePath): PropTypeDescriptor {
231
231
} else if (
232
232
t . CallExpression . check ( node ) &&
233
233
t . Identifier . check ( node . callee ) &&
234
- propTypes . hasOwnProperty ( node . callee . name )
234
+ propTypes . has ( node . callee . name )
235
235
) {
236
- descriptor = propTypes [ node . callee . name ] ( path . get ( 'arguments' , 0 ) ) ;
236
+ descriptor = propTypes . get ( node . callee . name ) ( path . get ( 'arguments' , 0 ) ) ;
237
237
} else {
238
238
descriptor = { name : 'custom' , raw : printValue ( path ) } ;
239
239
}
0 commit comments