DEV Community

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

Collapse
 
playground profile image
playground

Great article, thanks for sharing. Good to know there is another way of doing things.
I have been doing it the inverse by extending Request

For example:
export interface IRequest extends Request {
type: string;
sensorId: string;
timestamp: ITime;
}

in the server.ts
...
app.get("/test", (req: IRequest, res: IResponse) => {
...
})