.westsaid
.westsaid2y ago

NextJS & Keystone CMS, issues when connecting both in a monorepo

Hello everyone, so I have a monorepo with NextJS and keystone cms, both are running trpc v10beta.15. Screenshot 1: I receive a type error when trying to use the CmsAppRouter type in my NextJS when calling createTRPCProxyClient. Screenshot 2: The tRPC files in the cms. Does someone has a clue? Would be really thankful for any help 🙂 (Full error msg below)
6 Replies
.westsaid
.westsaid2y ago
Full Error Message
Type 'CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: string; code: TRPC_ERROR_COD...' does not satisfy the constraint 'Router<any>'.
The types returned by 'createCaller(...)' are incompatible between these types.
Type '{ query: inferHandlerFn<{}>; mutation: inferHandlerFn<{}>; subscription: inferHandlerFn<{}>; } & DecoratedProcedureRecord<{ translations: CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<...>; }; meta: {}; errorShape: { ...; }; transformer: CombinedDataTransformer; }, { ...;...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; } & DecoratedProcedureRecord<any>'.
Type '{ query: inferHandlerFn<{}>; mutation: inferHandlerFn<{}>; subscription: inferHandlerFn<{}>; } & DecoratedProcedureRecord<{ translations: CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<...>; }; meta: {}; errorShape: { ...; }; transformer: CombinedDataTransformer; }, { ...;...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; }'.
Types of property 'query' are incompatible.
Type 'inferHandlerFn<{}>' is not assignable to type 'inferHandlerFn<any>'.
Types of parameters 'path' and 'path' are incompatible.
Type 'TPath' is not assignable to type 'never'.
Type 'string' is not assignable to type 'never'.
Type 'CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: string; code: TRPC_ERROR_COD...' does not satisfy the constraint 'Router<any>'.
The types returned by 'createCaller(...)' are incompatible between these types.
Type '{ query: inferHandlerFn<{}>; mutation: inferHandlerFn<{}>; subscription: inferHandlerFn<{}>; } & DecoratedProcedureRecord<{ translations: CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<...>; }; meta: {}; errorShape: { ...; }; transformer: CombinedDataTransformer; }, { ...;...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; } & DecoratedProcedureRecord<any>'.
Type '{ query: inferHandlerFn<{}>; mutation: inferHandlerFn<{}>; subscription: inferHandlerFn<{}>; } & DecoratedProcedureRecord<{ translations: CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<...>; }; meta: {}; errorShape: { ...; }; transformer: CombinedDataTransformer; }, { ...;...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; }'.
Types of property 'query' are incompatible.
Type 'inferHandlerFn<{}>' is not assignable to type 'inferHandlerFn<any>'.
Types of parameters 'path' and 'path' are incompatible.
Type 'TPath' is not assignable to type 'never'.
Type 'string' is not assignable to type 'never'.
This can be considered closed. There was a problem with the config of the monorepo and the installed packages
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
.westsaid
.westsaid2y ago
Hi, I deleted node_modules, rechecked my monorepo configuration and reinstalled. The error disappeared. @Matheus Mazeto
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
.westsaid
.westsaid2y ago
Yes, turborepo. I reinstalled using yarn, then it worked Okay, I have to rollback, installed my repo on a new Pc, same issue again :/
Type 'CreateRouterInner<RootConfig<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | "BAD_REQUEST" | ... 10 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: s...' does not satisfy the constraint 'Router<any>'.
Type 'Router<RouterDef<RootConfig<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: string; code: TRPC...' is missing the following properties from type 'Router<any>': errorFormatter, transformerts(2344)
Type 'CreateRouterInner<RootConfig<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | "BAD_REQUEST" | ... 10 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: s...' does not satisfy the constraint 'Router<any>'.
Type 'Router<RouterDef<RootConfig<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: string; code: TRPC...' is missing the following properties from type 'Router<any>': errorFormatter, transformerts(2344)
If you or someone else want to start a debugging session sometimes hit me up. We could also set up an example project with "tRPC X Keystone JS CMS" which could be featured on the tRPC website Im setting up a boiled down version of this repo to debug and maybe feature later on rn!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View