kinsyu
kinsyu
Explore posts from servers
TtRPC
Created by kinsyu on 6/22/2024 in #❓-help
createTRPCReact cannot be named without a reference to x
Hey, I have a monorepo where I have a separate package for trpc (@repo/api) which I'm trying to use on the frontend. When trying to create createTRPCReact I'm getting the following type error
The inferred type of 'trpcReact' cannot be named without a reference to '../../node_modules/@repo/api/dist/router/post'. This is likely not portable. A type annotation is necessary.
The inferred type of 'trpcReact' cannot be named without a reference to '../../node_modules/@repo/api/dist/router/post'. This is likely not portable. A type annotation is necessary.
Here's my code on the react app
import type { inferReactQueryProcedureOptions } from "@trpc/react-query";
import { createTRPCReact } from "@trpc/react-query";

import type { AppRouter } from "@repo/api";

export type ReactQueryOptions = inferReactQueryProcedureOptions<AppRouter>;

const trpcReact = createTRPCReact<AppRouter>();

export default trpcReact;
import type { inferReactQueryProcedureOptions } from "@trpc/react-query";
import { createTRPCReact } from "@trpc/react-query";

import type { AppRouter } from "@repo/api";

export type ReactQueryOptions = inferReactQueryProcedureOptions<AppRouter>;

const trpcReact = createTRPCReact<AppRouter>();

export default trpcReact;
And here's the code in the api package
import { createHTTPServer } from "@trpc/server/adapters/standalone";
import cors from "cors";

import { postRouter } from "./router/post";
import { createTRPCContext, createTRPCRouter } from "./trpc";

export const appRouter = createTRPCRouter({
post: postRouter,
});

// export type definition of API
export type AppRouter = typeof appRouter;

// create server
createHTTPServer({
middleware: cors(),
router: appRouter,
createContext: createTRPCContext,
}).listen(2022);
import { createHTTPServer } from "@trpc/server/adapters/standalone";
import cors from "cors";

import { postRouter } from "./router/post";
import { createTRPCContext, createTRPCRouter } from "./trpc";

export const appRouter = createTRPCRouter({
post: postRouter,
});

// export type definition of API
export type AppRouter = typeof appRouter;

// create server
createHTTPServer({
middleware: cors(),
router: appRouter,
createContext: createTRPCContext,
}).listen(2022);
9 replies
TtRPC
Created by kinsyu on 5/21/2023 in #❓-help
tRPC Middleware consuming memory limit on Vercel
2 replies