Types Problem : Typescript generate ./DISTFile
Answered
Rex posted this in #help-forum
RexOP
When I start my Nest app for building with TRPC, the app router generates as 'any' in the
.d.ts file, but in the source file, types are available.Answered by Rex
Fixed: Problem in the latest version(Beta) of TRPC 11.x:
## solution :
## solution :
@Injectable()
export class TrpcRouter {
constructor(
private readonly trpcService: TrpcService,
private readonly transactionsRouter: TransactionsRouter,
private readonly employeesRouter: EmployeesRouter,
private readonly servicesServices: ServicesRouter,
) {}
appRouter = this.trpcService.mergeRouters(
this.transactionsRouter.router,
this.employeesRouter.router,
this.servicesServices.router,
);
getAppRouter() {
return this.appRouter;
}
}
export type AppRouter = ReturnType<TrpcRouter['getAppRouter']> ;
export type RouterInputs = inferRouterInputs<AppRouter>;
export type RouterOutputs = inferRouterOutputs<AppRouter>;3 Replies
RexOP
@Injectable()
export class TrpcRouter {
constructor(
private readonly trpcService: TrpcService,
private readonly transactionsRouter: TransactionsRouter,
private readonly employeesRouter: EmployeesRouter,
private readonly servicesServices: ServicesRouter,
) {}
appRouter = this.trpcService.mergeRouters(
this.transactionsRouter.router,
this.employeesRouter.router,
this.servicesServices.router,
)
}
export type AppRouter = TrpcRouter['appRouter'];
// Utility types for inputs and outputs
export type RouterInputs = inferRouterInputs<AppRouter>;
export type RouterOutputs = inferRouterOutputs<AppRouter>;RexOP
Fixed: Problem in the latest version(Beta) of TRPC 11.x:
## solution :
## solution :
@Injectable()
export class TrpcRouter {
constructor(
private readonly trpcService: TrpcService,
private readonly transactionsRouter: TransactionsRouter,
private readonly employeesRouter: EmployeesRouter,
private readonly servicesServices: ServicesRouter,
) {}
appRouter = this.trpcService.mergeRouters(
this.transactionsRouter.router,
this.employeesRouter.router,
this.servicesServices.router,
);
getAppRouter() {
return this.appRouter;
}
}
export type AppRouter = ReturnType<TrpcRouter['getAppRouter']> ;
export type RouterInputs = inferRouterInputs<AppRouter>;
export type RouterOutputs = inferRouterOutputs<AppRouter>;Answer