-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$client is unknown #91
Comments
Seems a definition file is needed: https://nuxt.com/docs/guide/directory-structure/plugins#advanced |
hey did you solve this? I am getting this in vscode V1.79.2 in V1.78.x $client is defined. |
@kylegl is this with trpc v9? |
I was struggling with the same issue. Here's how I fixed it. I am using tRPC 10, by the way. Updated import { createTRPCNuxtClient, httpBatchLink } from "trpc-nuxt/client";
import superjson from "superjson";
import { loggerLink } from "@trpc/client";
import type { AppRouter } from "~/server/trpc/routers";
export default defineNuxtPlugin(() => {
/**
* createTRPCNuxtClient adds a `useQuery` composable
* built on top of `useAsyncData`.
*/
const client = createTRPCNuxtClient<AppRouter>({
transformer: superjson,
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === "development" ||
(opts.direction === "down" && opts.result instanceof Error),
}),
httpBatchLink({
url: "/api/trpc",
}),
],
});
return {
provide: {
client,
},
};
});
export type client = ReturnType<typeof createTRPCNuxtClient<AppRouter>>; Then added an import { type client } from "./plugins/client";
declare module "#app" {
interface NuxtApp {
$client: client;
}
}
export {}; |
@ncpleslie that's weird. Nuxt should auto-infer the client type 🤔 |
Yip, I agree. Its obviously an issue with our (@kylegl @robsel118) set up but didn't want to see a closed issue without a potential solution. Alternatively, according to this stack overflow thread, delete your This isn't an issue with |
insane workaround |
I tried it and it still doesn't work |
I solved the problem by comparing this recommended nuxt-trpc guide to my project, and indeed the |
I think it's better to use |
I had the same problem after I run in vscode (cmd+shift+p) |
I also asked for adding trpc functionality in the todos demo from atinux. It could use some upvotes😉 |
I had the same problem. I've tried to disable modules step by step and after removing |
I’ve encountered a similar issue, but when using a specific srdDir configuration. It might be related to type generation from Nuxt itself. |
This fixed TRPC for our team. Thank you! The whole app is built around TRPC, so if intellisense is broken, it leaves new team members in the dark about types and where to find them. |
httpBatchLink({
url: "/api/trpc",
}), throws this error: Object literal may only specify known properties, and 'url' does not exist in type 'HttpBatchLinkOptions'. |
Wha
which trpc version are you on? |
@wobsoriano I had ^0.7.0 and update to ^0.10.22 fixed the issue |
I've followed the recommend setup for V9, however I don't get the auto-completion because $client is unknown. This happens on my own project, but also on the playground for this project.
I am using VS code. With V3 it was working before but not on V9.
Would you know what the issue is?
The text was updated successfully, but these errors were encountered: