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

c.Var types unknown #2559

Closed
janat08 opened this issue Apr 25, 2024 · 5 comments
Closed

c.Var types unknown #2559

janat08 opened this issue Apr 25, 2024 · 5 comments
Labels

Comments

@janat08
Copy link

janat08 commented Apr 25, 2024

What version of Hono are you using?

4.2.7

What runtime/platform is your app running on?

CF Workers

What steps can reproduce the bug?

`
const redirectHtmx: MiddlewareHandler<{
Variables: {
redirectHtmx: (url: string) => Response
}
}> = async (c, next) => {
c.set('redirectHtmx', (url: string) => new Response(null, {headers: {'HX-Location': url}}))
await next()
}
app.use('*', redirectHtmx)

c.var.redirectHtmx('/page') is of type unkown
`

What is the expected behavior?

https://hono.dev/api/context#var

What do you see instead?

is of type unkown on additional methods

Additional information

No response

@janat08 janat08 added the bug label Apr 25, 2024
@sor4chi
Copy link
Contributor

sor4chi commented Apr 25, 2024

I think you have to write the env generics to Hono instance.
Screenshot 2024-04-25 at 15 48 15

@janat08
Copy link
Author

janat08 commented Apr 25, 2024

Makes sense, but then the docs are wrong.

@sor4chi
Copy link
Contributor

sor4chi commented Apr 25, 2024

That's true. I'll fix it later!

@sor4chi
Copy link
Contributor

sor4chi commented Apr 30, 2024

Hi, @janat08
The website has been updated! Thanks!

@yusukebe
Copy link
Member

yusukebe commented May 1, 2024

@janat08 @sor4chi Thanks!

Closing the issue.

@yusukebe yusukebe closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants