hyper-express
hyper-express copied to clipboard
Improve Type Customization
This PR is a proof of concept implementing some ideas from #131 to ease hyper-express
usage with Typescript.
All I did was changing the type declarations to allow a bit of customization to benefit from Typescript type checks and autocompletion. You'll find rough examples inside a new markdown page soberly called Typescript.
The customization is inspired by Fastify generics with a simple object having multiple properties : {Body, Params, Locals}. In my Fastify projects I frequently use this handy type customization, I find it really useful to avoid type errors.
If maintainers appreciate the idea, we may also push the customization further and allow Response type customization and so on. I would be happy to discuss further customization and choices about the Generic form.
I love this underrated package btw 🫶