Thanks for the great work here.
I'm using your router (version 4/next.46) with Cloudflare Workers and there are some environment variables and a custom context object I'd like to pass into router.handle as the second/third argument (as illustrated in some of your own examples).
This works fine from a JavaScript standpoint, but the types are bad. Every RouteHandler function receives all arguments except the first (the properly typed IRequest object) as any, and there's no way to pass in custom types once, like it is common with other packages. You'd have to explicitly assert/cast the argument type for every function from any to the actual type even though it is already known (I'm running TypeScript and ESLint with very strict settings, so just ignoring the types is not an option). I ended up having to patch your TS declarations file to make it work.
Thanks for the great work here. I'm using your router (version 4/next.46) with Cloudflare Workers and there are some environment variables and a custom context object I'd like to pass into
router.handle
as the second/third argument (as illustrated in some of your own examples). This works fine from a JavaScript standpoint, but the types are bad. EveryRouteHandler
function receives all arguments except the first (the properly typedIRequest
object) asany
, and there's no way to pass in custom types once, like it is common with other packages. You'd have to explicitly assert/cast the argument type for every function fromany
to the actual type even though it is already known (I'm running TypeScript and ESLint with very strict settings, so just ignoring the types is not an option). I ended up having to patch your TS declarations file to make it work.Here is the diff that solved my problem:
Here a code snippet: