Skip to content
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

set method not working when passing a key and value #2484

Open
hariyebk opened this issue Apr 9, 2024 · 1 comment
Open

set method not working when passing a key and value #2484

hariyebk opened this issue Apr 9, 2024 · 1 comment

Comments

@hariyebk
Copy link

hariyebk commented Apr 9, 2024

What version of Hono are you using?

4.2.1

What runtime/platform is your app running on?

bun

What steps can reproduce the bug?

app.use(async (c, next) => { c.set('message', 'Hono is cool!!') await next() }) app.get("/", (c) => { const message = c.get("message") return c.text(${message}) })

What is the expected behavior?

It must work fine when passing the key "message" and the value "honor is cool!"

What do you see instead?

underneath the key, I encountered an error: "No overload matches this call.
Overload 1 of 2, '(key: never, value: never): void', gave the following error".

Additional information

No response

@hariyebk hariyebk added the bug label Apr 9, 2024
@yusukebe
Copy link
Member

Hi @hariyebk

It's not a bug. Try to pass the generics to new Hono:

type Variables = {
  message: string
}

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

@yusukebe yusukebe removed the bug label Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants