{"record":{"id":"0887bdabc39120e8","repo":"trpc/trpc","slug":"no-export-named-exportname-found-in-resolv","errorCode":null,"errorMessage":"No export named '${exportName}' found in: ${resolvedPath}\\nAvailable exports: ${available || '(none)'}","messagePattern":"No export named '(.+?)' found in: (.+?)\\\\nAvailable exports: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/openapi/src/generate.ts","lineNumber":1502,"sourceCode":"  const program = ts.createProgram([resolvedPath], compilerOptions);\n  const checker = program.getTypeChecker();\n  const sourceFile = program.getSourceFile(resolvedPath);\n\n  if (!sourceFile) {\n    throw new Error(`Could not load TypeScript file: ${resolvedPath}`);\n  }\n\n  const moduleSymbol = checker.getSymbolAtLocation(sourceFile);\n  if (!moduleSymbol) {\n    throw new Error(`No module exports found in: ${resolvedPath}`);\n  }\n\n  const tsExports = checker.getExportsOfModule(moduleSymbol);\n  const routerSymbol = tsExports.find((sym) => sym.getName() === exportName);\n\n  if (!routerSymbol) {\n    const available = tsExports.map((e) => e.getName()).join(', ');\n    throw new Error(\n      `No export named '${exportName}' found in: ${resolvedPath}\\n` +\n        `Available exports: ${available || '(none)'}`,\n    );\n  }\n\n  // Prefer the value declaration for value exports; fall back to the declared\n  // type for `export type AppRouter = …` aliases.\n  let routerType: ts.Type;\n  if (routerSymbol.valueDeclaration) {\n    routerType = checker.getTypeOfSymbolAtLocation(\n      routerSymbol,\n      routerSymbol.valueDeclaration,\n    );\n  } else {\n    routerType = checker.getDeclaredTypeOfSymbol(routerSymbol);\n  }\n\n  const schemaCtx: SchemaCtx = {","sourceCodeStart":1484,"sourceCodeEnd":1520,"githubUrl":"https://github.com/trpc/trpc/blob/acff82332de8b4562d3e6975fa8d94ab1a6de5e0/packages/openapi/src/generate.ts#L1484-L1520","documentation":"With the module symbol in hand, the generator enumerates exports and looks for one named `exportName` (default `'AppRouter'`). If none matches, it throws and lists the available export names so you can correct either the file or the `exportName` option.","triggerScenarios":"The router is exported under a different name (e.g., `export type Router` instead of `AppRouter`), or `options.exportName` was set to a value that isn't exported.","commonSituations":"Non-standard router naming, multiple routers in one file, or a typo in the `exportName` option.","solutions":["Read the `Available exports:` line in the error and either rename your export to `AppRouter` or pass `exportName: '<actualName>'`.","Add `export type AppRouter = typeof yourRouter` to the file.","Verify spelling/casing of the exportName option."],"exampleFix":"// before\n// src/router.ts: export type Router = typeof appRouter;\ngenerateOpenApiDocument('src/router.ts'); // default exportName 'AppRouter' missing\n\n// after — option A\ngenerateOpenApiDocument('src/router.ts', { exportName: 'Router' });\n// after — option B\nexport type AppRouter = typeof appRouter;","handlingStrategy":"validation","validationCode":"const expected = opts.exportName ?? 'AppRouter';\n// introspect via ts-morph or a regex for `export type ${expected} =`\nif (!new RegExp(`export\\\\s+type\\\\s+${expected}\\\\b`).test(src)) {\n  throw new Error(`File does not export '${expected}'`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await generateOpenApiDocument(resolvedPath, opts);\n} catch (e) {\n  if (e instanceof Error && /No export named/.test(e.message)) {\n    // set opts.exportName to an available export from the message\n  }\n  throw e;\n}","preventionTips":["Standardize on the `AppRouter` export name across the repo.","Pass `exportName` explicitly when the file uses a different name."],"tags":["openapi","codegen","typescript","exports","config"],"backgroundTag":null,"analyzedSha":"acff82332de8b4562d3e6975fa8d94ab1a6de5e0","analyzedAt":"2026-08-12T22:04:41.179Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}