#4257·trpc

feat(server): Stricter types for `AnyRouter` etc

Author: KATTCreated Apr 26, 2023Updated Sep 20, 2026
Labels@trpc/server🧙🏻 typescript wizardry✅ accepted-PRs-welcome

Essentially, I want a generic AnyRouter for a function that accepts a router, but inside the fn impl I want to be able to inspect router config. I want to be able to list procedures and their types.

Right now, if I pass as a generic, then all values of _def are any. I wish it was something like Record<string, ProecedureConfig> or some such.

image

In the actual router implementation, _def.procedures is an object, rather than any.

image

To be clear, I understand that I cannot infer the actual router impl inside the fn with a generic type, but I wish there was just some resemblance of the procedure type, e.g. just having a generic Record<string, Config>

Also asked on Discord: https://discord.com/channels/867764511159091230/1088066576303005786

Originally posted by @moltar in https://github.com/trpc/trpc/discussions/4093

TRP-24