I am using trpc in bunch of projects that are spread across npm packages. E.g., I have a server my-server
and a client my-client
. In my-client
code I am importing AppRouter
like this:
import type { AppRouter } from `my-server`;
I want to be able to publish AppRouter
types on NPM without exposing any sensitive information like my server source code or Context
of the AppRouter
.
When generating .d.ts files via tsc
or vite
, .d.ts files contain all imported type definitions. Since AppRouter
depends on Context
, and Context
usually contains all backend services (e.g., UsersService
, PaymentService
, etc), all the backend type declarations are also included in .d.ts files.
I see at least two solutions:
Context
object with unknown
when generating .d.ts filesappRouter
is defined in src/router.ts
, only include dist/router.d.ts
in package.json files
field.I hope trpc provides a recommended way to publish AppRouter
, so developers do not need to think about it themselves.
Don't provide a recommended way of publishing AppRouter
and leave it to devs.
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too