Skip to content

Type Alias: InferRouter<T>

ts
type InferRouter<T> = T extends TypedToolRegistry<infer _TCtx, infer TBuilders> ? InferRouterFromBuilders<TBuilders> : T extends readonly unknown[] ? InferRouterFromBuilders<T> : Record<string, Record<string, unknown>>;

Defined in: packages/core/src/client/InferRouter.ts:83

Infer a RouterMap from a TypedToolRegistry.

Extracts the accumulated TRouterMap from each builder registered in the typed registry, producing a flat intersection of all { 'toolName.actionName': ArgsType } entries.

Type Parameters

Type ParameterDescription
TA TypedToolRegistry instance type

Example

typescript
const projects = createTool<Ctx>('projects')
    .action({ name: 'list', schema: z.object({ status: z.string() }), handler: ... })
    .action({ name: 'create', schema: z.object({ name: z.string() }), handler: ... });

const registry = createTypedRegistry<Ctx>()(projects);
type AppRouter = InferRouter<typeof registry>;
// Result: {
//   'projects.list': { status: string };
//   'projects.create': { name: string };
// }