@@ -86,7 +86,7 @@ module.exports = {
8686 if  ( node . type  ===  'ExperimentalSpreadProperty'  ||  node . type  ===  'SpreadElement' )  { 
8787 return  null ; 
8888 } 
89-  if  ( node . value . property )  { 
89+  if  ( node . value   &&   node . value . property )  { 
9090 const  name  =  node . value . property . name ; 
9191 if  ( name  ===  'isRequired' )  { 
9292 if  ( node . value . object  &&  node . value . object . property )  { 
@@ -96,7 +96,7 @@ module.exports = {
9696 } 
9797 return  name ; 
9898 } 
99-  if  ( node . value . type  ===  'Identifier' )  { 
99+  if  ( node . value   &&   node . value . type  ===  'Identifier' )  { 
100100 return  node . value . name ; 
101101 } 
102102 return  null ; 
@@ -145,6 +145,16 @@ module.exports = {
145145 ) ; 
146146 } 
147147
148+  function  tsCheck ( prop )  { 
149+  if  ( prop . type  !==  'TSPropertySignature' )  return  false ; 
150+  const  typeAnnotation  =  ( prop . typeAnnotation  ||  { } ) . typeAnnotation ; 
151+  return  ( 
152+  typeAnnotation 
153+  &&  typeAnnotation . type  ===  'TSBooleanKeyword' 
154+  &&  rule . test ( getPropName ( prop ) )  ===  false 
155+  ) ; 
156+  } 
157+ 
148158 /** 
149159 * Checks if prop is nested 
150160 * @param  {Object } prop Property object, single prop type declaration 
@@ -170,7 +180,7 @@ module.exports = {
170180 runCheck ( prop . value . arguments [ 0 ] . properties ,  addInvalidProp ) ; 
171181 return ; 
172182 } 
173-  if  ( flowCheck ( prop )  ||  regularCheck ( prop ) )  { 
183+  if  ( flowCheck ( prop )  ||  regularCheck ( prop )   ||   tsCheck ( prop ) )  { 
174184 addInvalidProp ( prop ) ; 
175185 } 
176186 } ) ; 
@@ -289,6 +299,12 @@ module.exports = {
289299 } 
290300 } , 
291301
302+  TSTypeAliasDeclaration ( node )  { 
303+  if  ( node . typeAnnotation . type  ===  'TSTypeLiteral' )  { 
304+  objectTypeAnnotations . set ( node . id . name ,  node . typeAnnotation ) ; 
305+  } 
306+  } , 
307+ 
292308 // eslint-disable-next-line object-shorthand 
293309 'Program:exit' ( )  { 
294310 if  ( ! rule )  { 
@@ -299,22 +315,30 @@ module.exports = {
299315 Object . keys ( list ) . forEach ( ( component )  =>  { 
300316 // If this is a functional component that uses a global type, check it 
301317 if  ( 
302-  list [ component ] . node . type  ===  'FunctionDeclaration' 
318+  ( 
319+  list [ component ] . node . type  ===  'FunctionDeclaration' 
320+  ||  list [ component ] . node . type  ===  'ArrowFunctionExpression' 
321+  ) 
303322 &&  list [ component ] . node . params 
304323 &&  list [ component ] . node . params . length 
305324 &&  list [ component ] . node . params [ 0 ] . typeAnnotation 
306325 )  { 
307326 const  typeNode  =  list [ component ] . node . params [ 0 ] . typeAnnotation ; 
308327 const  annotation  =  typeNode . typeAnnotation ; 
309- 
310328 let  propType ; 
311329 if  ( annotation . type  ===  'GenericTypeAnnotation' )  { 
312330 propType  =  objectTypeAnnotations . get ( annotation . id . name ) ; 
313331 }  else  if  ( annotation . type  ===  'ObjectTypeAnnotation' )  { 
314332 propType  =  annotation ; 
333+  }  else  if  ( annotation . type  ===  'TSTypeReference' )  { 
334+  propType  =  objectTypeAnnotations . get ( annotation . typeName . name ) ; 
315335 } 
336+ 
316337 if  ( propType )  { 
317-  validatePropNaming ( list [ component ] . node ,  propType . properties ) ; 
338+  validatePropNaming ( 
339+  list [ component ] . node , 
340+  propType . properties  ||  propType . members 
341+  ) ; 
318342 } 
319343 } 
320344
0 commit comments