Confused by recommendation to compile Hono App and Client

My question is specifically regarding this section of the documentation https://hono.dev/docs/guides/rpc#compile-your-code-before-using-it-recommended I want to compile the types for my Hono client to take some of the workload off TSServer and utilise TSC, and because the VSCode extension for SvelteKit is incorrectly typing the responses returned from the client. I have set up a Deno task and a tsconfig to run tsc on this code:
// #region Imports

/*
Import to get environment variables.
Only get shared environment variables or this client will not work and could
be unsafe.
*/
import env from "@/env.ts"

// Create Hono client
import { hc } from "hono/client"


// Import types
import type { App } from "~db-api/server/src/lib/create-app.ts"

// #endregion Imports



/*
Create a mock client to speed up the TypeScript language server

Trick from the Hono docs:
https://hono.dev/docs/guides/rpc#compile-your-code-before-using-it-recommended
*/
const mockClient = hc<App>("")
export type Client = typeof mockClient


// Subroutine to create a client for this API
export const createApiClient = (): Client => {
return hc<App>(`http://localhost:${env.DATABASE_API_PORT}`)
}
// #region Imports

/*
Import to get environment variables.
Only get shared environment variables or this client will not work and could
be unsafe.
*/
import env from "@/env.ts"

// Create Hono client
import { hc } from "hono/client"


// Import types
import type { App } from "~db-api/server/src/lib/create-app.ts"

// #endregion Imports



/*
Create a mock client to speed up the TypeScript language server

Trick from the Hono docs:
https://hono.dev/docs/guides/rpc#compile-your-code-before-using-it-recommended
*/
const mockClient = hc<App>("")
export type Client = typeof mockClient


// Subroutine to create a client for this API
export const createApiClient = (): Client => {
return hc<App>(`http://localhost:${env.DATABASE_API_PORT}`)
}
Into a folder located relatively at "../dist". But how do I get TSServer to use the types output in this folder? Can someone share their implementation?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?