RaineP
RaineP15mo ago

Incompatible Router Types

I am working on a trpc implementation for sveltekit. I attached a screenshot of the createContext function, the fetchRequestHandlers, and the client. Everything works but I am getting a typescript error that is breaking auto-complete. I will comment the error below.
No description
No description
No description
1 Reply
RaineP
RainePOP15mo ago
Type 'CreateRouterInner<RootConfig<{ ctx: Ctx; meta: object; errorShape: { data: { zodError: typeToFlattenedError<any, string> | null; code: "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; mes...' is not assignable to type 'AnyRouter'.
The types returned by 'createCaller(...)' are incompatible between these types.
Type 'DecoratedProcedureRecord<{ auth: CreateRouterInner<RootConfig<{ ctx: Ctx; meta: object; errorShape: { data: { zodError: typeToFlattenedError<any, string> | null; code: "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; s...' is not assignable to type 'DecoratedProcedureRecord<any> & { query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; }'.
Type 'DecoratedProcedureRecord<{ auth: CreateRouterInner<RootConfig<{ ctx: Ctx; meta: object; errorShape: { data: { zodError: typeToFlattenedError<any, string> | null; code: "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; s...' is not assignable to type 'DecoratedProcedureRecord<any>'.
Property 'query' is incompatible with index signature.
Type 'inferHandlerFn<{}>' is not assignable to type 'DecoratedProcedureRecord<any> | DecorateProcedure<any>'.
Type 'inferHandlerFn<{}>' is not assignable to type 'DecorateProcedure<any>'.
Types of parameters 'path' and 'input' are incompatible.
Type 'any' is not assignable to type 'never'.ts(2322)
types.d.ts(13, 5): The expected type comes from property 'router' which is declared here on type 'FetchHandlerRequestOptions<AnyRouter>'
Type 'CreateRouterInner<RootConfig<{ ctx: Ctx; meta: object; errorShape: { data: { zodError: typeToFlattenedError<any, string> | null; code: "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; mes...' is not assignable to type 'AnyRouter'.
The types returned by 'createCaller(...)' are incompatible between these types.
Type 'DecoratedProcedureRecord<{ auth: CreateRouterInner<RootConfig<{ ctx: Ctx; meta: object; errorShape: { data: { zodError: typeToFlattenedError<any, string> | null; code: "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; s...' is not assignable to type 'DecoratedProcedureRecord<any> & { query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; }'.
Type 'DecoratedProcedureRecord<{ auth: CreateRouterInner<RootConfig<{ ctx: Ctx; meta: object; errorShape: { data: { zodError: typeToFlattenedError<any, string> | null; code: "PARSE_ERROR" | "BAD_REQUEST" | "INTERNAL_SERVER_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; s...' is not assignable to type 'DecoratedProcedureRecord<any>'.
Property 'query' is incompatible with index signature.
Type 'inferHandlerFn<{}>' is not assignable to type 'DecoratedProcedureRecord<any> | DecorateProcedure<any>'.
Type 'inferHandlerFn<{}>' is not assignable to type 'DecorateProcedure<any>'.
Types of parameters 'path' and 'input' are incompatible.
Type 'any' is not assignable to type 'never'.ts(2322)
types.d.ts(13, 5): The expected type comes from property 'router' which is declared here on type 'FetchHandlerRequestOptions<AnyRouter>'
I managed to resolve this by un-installing and re-installing the @trpc/server and @trpc/client packages