Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

203
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda