H
Hono4d ago
shcwork

RPC client shows 'any'

Hi, I currently working on getting frontend api with types. But when I do it, it shows
Element implicitly has an 'any' type because expression of type '":shift_date"' can't be used to index type 'ClientRequest<{ [x: `$${Lowercase<string>}`]: { input: any; output: any; outputFormat: string; status: StatusCode; }; }>'.
Property ':shift_date' does not exist on type 'ClientRequest<{ [x: `$${Lowercase<string>}`]: { input: any; output: any; outputFormat: string; status: StatusCode; }; }>'
Element implicitly has an 'any' type because expression of type '":shift_date"' can't be used to index type 'ClientRequest<{ [x: `$${Lowercase<string>}`]: { input: any; output: any; outputFormat: string; status: StatusCode; }; }>'.
Property ':shift_date' does not exist on type 'ClientRequest<{ [x: `$${Lowercase<string>}`]: { input: any; output: any; outputFormat: string; status: StatusCode; }; }>'
in /server/app.ts I did define routes as the docs recommended.
const apiRoutes = app
.basePath("/api")
.route("/attendance", attendanceRoute)
export default app;
export type ApiRoutes = typeof apiRoutes;
const apiRoutes = app
.basePath("/api")
.route("/attendance", attendanceRoute)
export default app;
export type ApiRoutes = typeof apiRoutes;
No description
No description
No description
6 Replies
ambergristle
ambergristle4d ago
When you do api.attendance.getShiftInfo, what are the autocomplete options? This might be helpful: https://hono.dev/docs/guides/rpc#compile-your-code-before-using-it-recommended
shcwork
shcworkOP4d ago
No description
ambergristle
ambergristle4d ago
With a monorepo, you’ll want to use generated types. The link I shared about compiling the client may also help
shcwork
shcworkOP4d ago
Ok will try on that
shcwork
shcworkOP4d ago
https://catalins.tech/hono-rpc-in-monorepos/ ahh ic, is the tsconfig.json problem, now resolved, thx alot!
Catalin's Tech
Hono RPC And TypeScript Project References
Learn how to use the Hono RPC in codebases with the backend separated from the frontend. The solution uses TypeScript's project references.
No description
Eternal
Eternal3d ago
you should mark the thread as "solved" btw

Did you find this page helpful?