DEV Community

Discussion on: Extend Express's Request Object with Typescript Declaration Merging.

Collapse
 
vkyrychenko profile image
Vitalii

Nice article! You saved my day 😎👍

I see a lot of libraries using this approach.

But It looks a bit strange for me. Just imagine that you have a lot of middleware that attaches something to the request object. In the end, you have a bloated interface and you lose the power of TypeScript because you don't know which middlewares were executed before handler/controller. So you don't know if the required data was attached and need to double-check if it's there 🤷‍♂️.