createTRPCNext returns strings, cannot use .withTRPC()

createTRPCNext returns error strings so I cannot use its withTRPC method.
export const api = createTRPCNext<AppRouter>({
config() {
return {
transformer: superjson,

links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === "development" ||
(opts.direction === "down" && opts.result instanceof Error),
}),
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
}),
],
};
},
ssr: false,
});
export const api = createTRPCNext<AppRouter>({
config() {
return {
transformer: superjson,

links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === "development" ||
(opts.direction === "down" && opts.result instanceof Error),
}),
httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
}),
],
};
},
ssr: false,
});
⤴️ this was copied from one of the examples so should cause the error. the type of AppRouter is definitely correct (and is correctly imported) and has no routers/procedures named as the error suggests <- this was also copied from an example what else can cause this error? help or any ideas would be appreciated, thanks! 🫶
9 Replies
cje
cje16mo ago
does this happen on a stock t3 app?
SGeri
SGeri16mo ago
not at all i'm pretty sure it is related to how i handle type imports @cje i'd appreciate it if you could take a look on the repo https://github.com/SGeri/expo-next-trpc what i can tell is that vscode doesnt give any references where i import the AppRouter type
SGeri
SGeri16mo ago
SGeri
SGeri16mo ago
meanwhile it does give info in the create-t3-turbo repo which should be similar (if not the same) at this point
SGeri
SGeri16mo ago
the only difference between the importing method is that all of my dependencies are in the root package.json not split into each app/package but as far as i know it shouldnt be a problem
cje
cje16mo ago
it works when you just stick a createTRPCNext in the same file as where the app router is so its something about your monorepo setup
SGeri
SGeri16mo ago
well yes but what can i do about it? ive tried renaming the package to anything else and even importing it directly from the next's package.json but that way npm i didnt even run
SGeri
SGeri16mo ago
SGeri
SGeri16mo ago
but @packages/api is definitely valid, it is defined in the package's package.json