Convert express Response to http ServerResponse

Viewed 459

I am using both express and http-proxy. After updating NodeJs types I am getting a type error:

TS2345: Argument of type 'Response<any, Record<string, any>>' is not assignable to parameter of type 'ServerResponse'.   Types of property 'req' are incompatible.     Type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>> | undefined' is not assignable to type 'IncomingMessage'.       Type 'undefined' is not assignable to type 'IncomingMessage'.

in the following code block:

async proxyCall(req: Request, res: Response): Promise<ProxyCallResponse> {
  return new Promise((resolve, reject) => {
    this.pendingPromises.set(req, {resolve, reject});
    this.proxy.web(req, res);
  });
}

so now I am not sure how to convert that Response input (coming from express) to the ServerResponse type that http-proxy seems to be expecting.

Any suggestion?

0 Answers
Related