klitchevo
Explore posts from serversIssue creating server - v11
I have nest.js app and I am running tRPC inside of it, however when I want to instantiate router I get typescript errors:
private readonly trpc = initTRPC.context<ContextType>().create();
middleware = this.trpc.middleware;
procedure = this.trpc.procedure;
router = this.trpc.router;
In my other file I have
appRouter = this.trpc.router({
hello: this.trpc.procedure.query(() => {
return { message: "Hello, World!" };
}),
});
also
app.use(
/trpc,
trpcExpress.createExpressMiddleware({
router: this.appRouter,
}),
);
I get error like this:
TS2322: Type
CreateRouterInner<RootConfig<{ ctx: { authenticated: boolean; req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>; res: Response<any, Record<string, any>>; }; meta: object; errorShape: never; transformer: DataTransformerOptions; }>, { ...; }>
is not assignable to type AnyRouter
Types of property _def are incompatible.
Type 'RouterDef<RootConfig<{ ctx: { authenticated: boolean; req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>; res: Response<any, Record<string, any>>; }; meta: object; errorShape: never; transformer: DataTransformerOptions; }>, { ...; }, { ...; }>' is not assignable to type 'AnyRouterDef<AnyRootConfig, any>'.
Type 'RootConfig<{ ctx: { authenticated: boolean; req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>; res: Response<any, Record<string, any>>; }; meta: object; errorShape: never; transformer: DataTransformerOptions; }>' is not assignable to type 'AnyRootConfig'.
Type any is not assignable to type never
Any ideas? Thanks in advance!2 replies