Closed tgriesser closed 1 year ago
I'm in the middle of a massive overhaul, bringing extras into core, with a full rewrite in TS... I need to tease this issue/PR back apart to see how to proceed, but no matter what, I'd like to be able to merge something so you end up on the contributors list :)
I'll let you know if I need it dialed back so we can get your name on the board... stay tuned!
Just added this request for help https://github.com/kwhitley/itty-router/issues/122... but you may be a good candidate for saving the day! :)
I'm gonna close this for now, as v3 is out (with a complete TS overhaul), but feel free to reopen to discuss further, or hop on Discord (ideally) to continue the conversation there! :)
A scaled down version of #118, only updating the
itty-router.d.ts
file:Summary of type changes:
Router<Request, Methods>
->Router<{ methodExtension: Methods }>
Request
defaults to the current globalRequest
, any extension can be made via declaration mergingRequest
on individual route handlersAdditional features:
/some/:path/:id?
->req.params
is{ path: string, id?: string | undefined }
without any additional workreq.method
propertyRouter<{ handlerArgs: [Env, ExecutionContext] }>
, which means they'll be typed correctly both on.handle
, and on all route handlers automaticallyRouter<{ handlerReturn: Response }>
Response | void
if you support passthrough handlers, but it defaults toany
to match current behaviorRequest
is as expected when the@cloudflare/workers-types
are in the global scope