Sakib
Sakib
Explore posts from servers
HHono
Created by Sakib on 5/20/2024 in #help
Type 'Hono<App {...}>' does not satisfy the constraint 'Hono<any, any, any> Property '#private' in t
Hi, I'm trying to use hono RPC client on my frontend project. But the type not working properly. I'm using "hono": "^4.3.7", on server and client. // On /web-api/src/routes/index.ts [Server]
import { App } from "@/@types/app";
import { Hono } from "hono";
import UserRoutes from "@/routes/users";

const app = new Hono<App>().route("/users", UserRoutes);

export type AppType = typeof app;
export default app;
import { App } from "@/@types/app";
import { Hono } from "hono";
import UserRoutes from "@/routes/users";

const app = new Hono<App>().route("/users", UserRoutes);

export type AppType = typeof app;
export default app;
// On /web-api/src/routes/users/index.ts [Server]
import { App } from "@/@types/app";
import { Hono } from "hono";

const app = new Hono<App>()
.get("/", async (c) => {
return c.json({});
})
.get("/test", async (c) => {
return c.json({});
});

export default app;
import { App } from "@/@types/app";
import { Hono } from "hono";

const app = new Hono<App>()
.get("/", async (c) => {
return c.json({});
})
.get("/test", async (c) => {
return c.json({});
});

export default app;
// On /web-api/tsconfig.json [Server]
{
"compilerOptions": {
"composite": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"lib": ["ESNext"],
"types": ["@cloudflare/workers-types"],
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx",
"paths": {
"@/*": ["./src/*"]
}
}
}
{
"compilerOptions": {
"composite": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"lib": ["ESNext"],
"types": ["@cloudflare/workers-types"],
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx",
"paths": {
"@/*": ["./src/*"]
}
}
}
// On /web-ui/tsconfig.json [Client]
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Other */
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@api/*": ["../web-api/src/*"]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }, { "path": "../web-api" }]
}
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Other */
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@api/*": ["../web-api/src/*"]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }, { "path": "../web-api" }]
}
3 replies