Closed AdiRishi closed 1 year ago
Hey @yusukebe
I just tried the fix you pushed in 3.6.1
and it does fix the reported problem š .
Unfortunately I found a few new type errors that still exist in 3.6.1
, I'll list them below, but let me know if you want me to open a new issue to deal with them
Code example:
import { middleware } from 'hono/factory'; // import for the second code block (attempted re-write)
export const internalRouter = new Hono<{ Bindings: Env }>();
// Old code before 3.6.x
// This used to work, but the middleware(c,next) line throws an error as it doesn't like the type of c anymore
// internalRouter.use('*', async (c, next) => {
// const middleware = bearerAuth({ token: c.env.TURBO_TOKEN });
// await middleware(c, next);
// });
// I tried to re-write this using the new middleware helper you made, but it also has a type error
internalRouter.use(
'*',
middleware(async (c, next) => {
const authMiddleware = bearerAuth({ token: c.env?.TURBO_TOKEN });
await authMiddleware(c, next);
})
);
In the re-write I tied with the new middleware helper, the type of c.env
doesn't seem to properly contain the Env
type that I'm passing in? E.g c.env.TURBO_TOKEN
is of type unknown
.
@AdiRishi
Hi! That issue might be fixed in v3.6.2 released now. Try it!
Just updated to 3.6.3
and everything is working great, than you š
Nice!
What version of Hono are you using?
3.6.0
What runtime/platform is your app running on?
Cloudflare Workers
What steps can reproduce the bug?
Env
interface for workers. E.gWhat is the expected behavior?
The type of
c.env.R2_BUCKET
should beR2Bucket
What do you see instead?
The type of
c.env.R2_BUCKET
isany
because the type ofc.env
is now anyAdditional information
If a reproduction repository helps, you can check the
renovate/hono-3.x
branch on https://github.com/AdiRishi/turborepo-remote-cache-cloudflareTo setup the repository, just clone it and run
yarn install
, the specific line which can showcase this error is at https://github.com/AdiRishi/turborepo-remote-cache-cloudflare/blob/renovate/hono-3.x/src/routes/v8/artifacts.ts#L62