@@ -25,6 +25,7 @@ describe("function declarations test", () => {
2525 const funDecls : Map < string , LCEFunctionDeclaration > = new Map ( ) ;
2626 let dependencies : Map < string , Map < string , LCEDependency > > ;
2727 let mainModule : LCEModule ;
28+ let indexModule : LCEModule ;
2829
2930 beforeAll ( async ( ) => {
3031 const projects = await processProjects ( projectRootPath ) ;
@@ -54,6 +55,12 @@ describe("function declarations test", () => {
5455 }
5556 mainModule = mainModuleConcept as LCEModule ;
5657
58+ const indexModuleConcept = result . get ( LCEModule . conceptId ) ?. find ( ( mod ) => ( mod as LCEModule ) . fqn . localFqn === "./src/MyComponent/index.ts" ) ;
59+ if ( ! indexModuleConcept ) {
60+ throw new Error ( "Could not find main module in result data" ) ;
61+ }
62+ indexModule = indexModuleConcept as LCEModule ;
63+
5764 dependencies = getDependenciesFromResult ( result ) ;
5865 } ) ;
5966
@@ -540,4 +547,32 @@ describe("function declarations test", () => {
540547 1 ,
541548 ) ;
542549 } ) ;
550+
551+ test ( "function within index.ts with single parameter of referenced class type" , async ( ) => {
552+ const decl = funDecls . get ( '"./src/MyComponent".MyComponent' ) ;
553+ expect ( decl ) . toBeDefined ( ) ;
554+ if ( decl ) {
555+ expect ( decl . coordinates . fileName ) . toBe ( indexModule . path ) ;
556+ expect ( decl . fqn . globalFqn ) . toBe ( resolveGlobalFqn ( projectRootPath , '"./src/MyComponent".MyComponent' ) ) ;
557+ expect ( decl . functionName ) . toBe ( "MyComponent" ) ;
558+
559+ expectPrimitiveType ( decl . returnType , "number" ) ;
560+
561+ expect ( decl . parameters ) . toHaveLength ( 1 ) ;
562+ expectFunctionParameter ( decl . parameters , 0 , "props" , false ) ;
563+ expectDeclaredType ( decl . parameters [ 0 ] ! . type , resolveGlobalFqn ( projectRootPath , '"./src/MyComponent".MyComponentPropType' ) ) ;
564+
565+ expect ( decl . async ) . toBe ( false ) ;
566+
567+ expect ( decl . typeParameters ) . toHaveLength ( 0 ) ;
568+ }
569+
570+ expectDependency (
571+ projectRootPath ,
572+ dependencies ,
573+ '"./src/MyComponent".MyComponent' ,
574+ resolveGlobalFqn ( projectRootPath , '"./src/MyComponent".MyComponentPropType' ) ,
575+ 1 ,
576+ ) ;
577+ } ) ;
543578} ) ;
0 commit comments