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

208
Views
¿Cómo extender las interfaces de solicitud y respuesta expresas?

Quiero extender las interfaces de Request y Response expresas, lo hago así:

 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; } } }

En mi código, puedo acceder a req.body y res.json sin errores, pero cuando intento acceder a otras propiedades de express.Request o express.Response (por ejemplo, req.params ), aparece un error en VS Code que esta propiedad no existe en el tipo Express.Request o Express.Response , aunque mis interfaces amplían los tipos de Request y Response originales.

¿Por qué no puedo usar las propiedades express.Request y express.Response ?

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!