tRPCttRPC
Powered by
NotZeldaN
tRPC•10mo ago•
1 reply
NotZelda

Is there a typescript performance gain if I infer my router outputs once, and then export them?

You can infer your router outputs using RouterOutputs["router"]["procedure"]. Should I just use this directly on the objects I want to pass this type through, or should I declare these once in a RouterOutputs file, and export a named type?

Potentially if the traversal of the RouterOutputs type helper is expensive typescript could cache this result easier with a named export. Im just not sure if this is a reality or best practice?
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

if I export 'appRouter' instead of 'router' I get error
NazCodelandNNazCodeland / ❓-help
3y ago
Validating inputs and outputs only via typescript
DangerZoneDDangerZone / ❓-help
2y ago
Complex type inference on router outputs?
ianIian / ❓-help
2y ago