Can't use custom type for Request and Response objects in Express 5 #5937
Replies: 3 comments
-
Hi, I'm new to open source contribution, how can i solve issue.
|
Beta Was this translation helpful? Give feedback.
-
I'm afraid that you have to extend the FYI Express type definitions are maintained in the DefinitelyTyped project and there are no Express 5 specific definitions (I think that the v4 types should be good enough for most use cases). |
Beta Was this translation helpful? Give feedback.
-
Hello, I had a similar problem and if I am not mistaken, I solved it by making the property optional. |
Beta Was this translation helpful? Give feedback.
-
Hi. I am trying to use a custom middleware which injects the users company in either the request or response objects. I don't want to use
declare global
for this, as not all of my requests in the app will use this custom middleware. I tried a couple of things, and everything gives me some sort of typescript errorI also tried all of these interfaces:
Nothing works. All errors are something along the lines of this one:
How to properly extend either the request or response objects?????
Beta Was this translation helpful? Give feedback.
All reactions