@@ -226,6 +226,7 @@ export class Parser {
226226 private readonly shouldIncludePropTagMap : boolean ;
227227 private readonly shouldIncludeExpression : boolean ;
228228 private propertiesOfPropsCache : Map < string , PropItem > = new Map ( ) ;
229+ private componentsInfoCache : Map < string , ComponentDoc | null > = new Map ( ) ;
229230
230231 constructor ( program : ts . Program , opts : ParserOptions ) {
231232 const {
@@ -300,11 +301,17 @@ export class Parser {
300301 const typeSymbol = type . symbol || type . aliasSymbol ;
301302 const originalName = rootExp . getName ( ) ;
302303 const filePath = source . fileName ;
304+ const cacheKey = `${ filePath } _${ originalName } ` ;
305+
306+ if ( this . componentsInfoCache . has ( cacheKey ) ) {
307+ return this . componentsInfoCache . get ( cacheKey ) as ComponentDoc | null ;
308+ }
303309
304310 if ( ! rootExp . valueDeclaration ) {
305311 if ( ! typeSymbol && ( rootExp . flags & ts . SymbolFlags . Alias ) !== 0 ) {
306312 commentSource = this . checker . getAliasedSymbol ( commentSource ) ;
307313 } else if ( ! typeSymbol ) {
314+ this . componentsInfoCache . set ( cacheKey , null ) ;
308315 return null ;
309316 } else {
310317 rootExp = typeSymbol ;
@@ -347,6 +354,7 @@ export class Parser {
347354 ( typeSymbol . getEscapedName ( ) === 'Requireable' ||
348355 typeSymbol . getEscapedName ( ) === 'Validator' )
349356 ) {
357+ this . componentsInfoCache . set ( cacheKey , null ) ;
350358 return null ;
351359 }
352360
@@ -366,6 +374,7 @@ export class Parser {
366374 let result : ComponentDoc | null = null ;
367375 if ( propsType ) {
368376 if ( ! commentSource . valueDeclaration ) {
377+ this . componentsInfoCache . set ( cacheKey , null ) ;
369378 return null ;
370379 }
371380 const defaultProps = this . extractDefaultPropsFromComponent (
@@ -405,6 +414,7 @@ export class Parser {
405414 result . rootExpression = exp ;
406415 }
407416
417+ this . componentsInfoCache . set ( cacheKey , result ) ;
408418 return result ;
409419 }
410420
0 commit comments