Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

195
Views
How to extend express request and response interfaces?

I want to extend express Request and Response interfaces, i do it like this:

import express from 'express';

interface ResponseBody<T = any> {
    data?: T;
    error?: string;
}

declare global {
    namespace Express {
        export interface Request<T = any> extends express.Request {
            body: T;
        }

        export interface Response extends express.Response {
            json: (body?: ResponseBody) => this;
        }
    }
}

In my code i can access req.body and res.json with no errors, but when i'm trying to access other properties of express.Request or express.Response (e.g. req.params), i get an error in VS Code that this property doesn't exist in Express.Request or Express.Response type, although my interfaces extend original Request and Response types.

Why i'm not able to use express.Request and express.Response properties?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!