Skip to content

new Hono<{ Bindings: Env }>(); seems incompatible with Cloudflare wrangler generated type Env #3080

Answered by yusukebe
GregoryZeng asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @GregoryZeng

Do you have any idea for this problem?

Below are my ideas.

  1. Don't use an interface. Use a type instead of it.
  2. You can refer to the following code:
interface Env {
  MY_VARIABLE: 'production_value'
  MY_BUCKET: R2Bucket
  MY_DB: D1Database
}

type Bindings = {
  [key in keyof Env]: Env[key]
}

const app = new Hono<{ Bindings: Bindings }>()

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@GregoryZeng
Comment options

Answer selected by GregoryZeng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants