From 8601f85f56c2f1002cb67dd990c9dcad79c4f5ff Mon Sep 17 00:00:00 2001 From: Gergo Magyar Date: Mon, 21 Sep 2026 08:03:48 +0000 Subject: [PATCH] Address PR review feedback (#3339) Recognize type-annotated `const adminRouter: AppRouter = t.router(` bindings so identifier mounts still compose. Co-authored-by: Cursor --- .../src/core/ingestion/route-extractors/trpc.ts | 2 +- gitnexus/test/unit/trpc-route-extractor.test.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gitnexus/src/core/ingestion/route-extractors/trpc.ts b/gitnexus/src/core/ingestion/route-extractors/trpc.ts index d9931c952..27a619186 100644 --- a/gitnexus/src/core/ingestion/route-extractors/trpc.ts +++ b/gitnexus/src/core/ingestion/route-extractors/trpc.ts @@ -405,7 +405,7 @@ const ROUTER_OPEN_RE = // Same-file `const adminRouter = t.router({` / `createTRPCRouter(` / bare `router(`. const ROUTER_BINDING_RE = - /(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(?:(?:t|trpc|tRPC)\s*\.\s*router|createTRPCRouter|router)\s*\(/; + /(?:export\s+)?(?:const|let|var)\s+(\w+)(?:\s*:\s*[^=]+)?\s*=\s*(?:(?:t|trpc|tRPC)\s*\.\s*router|createTRPCRouter|router)\s*\(/; // Identifier composition: `admin: adminRouter,` / last-property `admin: adminRouter`. // Optional `as` / `satisfies` tail (`admin: adminRouter as const`) still mounts. diff --git a/gitnexus/test/unit/trpc-route-extractor.test.ts b/gitnexus/test/unit/trpc-route-extractor.test.ts index b62a86774..412bae2f5 100644 --- a/gitnexus/test/unit/trpc-route-extractor.test.ts +++ b/gitnexus/test/unit/trpc-route-extractor.test.ts @@ -546,6 +546,19 @@ describe('extractTrpcRoutes', () => { expect(paths(source)).toEqual(['GET /trpc/admin.list', 'GET /trpc/health']); }); + it('type-annotated router bindings still compose identifier mounts', () => { + const source = [ + "import { initTRPC } from '@trpc/server';", + 'const t = initTRPC.create();', + 'const publicProcedure = t.procedure;', + 'const adminRouter: AppRouter = t.router({', + ' list: publicProcedure.query(() => null),', + '});', + 'export const appRouter = t.router({ admin: adminRouter });', + ].join('\n'); + expect(paths(source)).toEqual(['GET /trpc/admin.list']); + }); + it('identifier mount still composes with an inline nest inside the subrouter', () => { const source = [ "import { initTRPC } from '@trpc/server';",