What is a reason of having ResBody generic type inside Request interface?

Viewed 243

The index.d.ts file of the express lib has the next interface

interface Request<P extends core.Params = core.ParamsDictionary, ResBody = any, ReqBody = any, ReqQuery = core.Query> extends core.Request<P, ResBody, ReqBody, ReqQuery> { }

What is a reason to pass ResBody generic type to the Request interface?

As far I understand this should be assigned to the req object of middleware

  expressMiddleware(
    req: Request<{}, ResBody, ReqBody, ReqQuery>,
    res: Response<ResBody>,
    next: NextFunction,
  ) {}

But Response type has own generic for this case.

Could you please clarify me this question?

0 Answers
Related