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

562
Vistas
An interface can only extend an identifier/qualified-name with optional type arguments. ts(2499)

I am trying to create a new extended interface for express.RequestHandler but this error seems to come up. I cannot understand why.

An interface can only extend an identifier/qualified-name with optional type arguments. ts(2499)

The express.RequestHandler interface does not support async functions. It says

The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>>'?ts(1064)

Here are my interfaces

export interface IRequest extends express.Request {
    user: IUser;
}

export interface IRequestHandler extends RequestHandler = (
    req: IRequest,
    res: express.Response,
    next: express.NextFunction
) => void | Promise<void>;
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It seems you are trying to extend the express.Request interface.

Try:

import { NextFunction, Request, Response } from 'express';

interface IUser {
  name: string;
}

declare module 'express' {
  interface Request {
    user: IUser;
  }
}

const controller = async (req: Request, res: Response, next: NextFunction) => {
  console.log(req.user);
};

enter image description here

about 4 years ago · Santiago Trujillo Denunciar
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