node.js - Konvertera express Response till http ServerResponse
Jag använder både express och http-proxy. Efter att ha uppdaterat NodeJs-typerna får jag ett typfel:
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'.
i följande kodblock:
async proxyCall(req: Request, res: Response): Promise<ProxyCallResponse> {
return new Promise((resolve, reject) => {
this.pendingPromises.set(req, {resolve, reject});
this.proxy.web(req, res);
});
}
så nu är jag inte säker på hur jag ska konvertera det Response-indata (som kommer från express) till ServerResponse-typen som http-proxy verkar förvänta sig.
Några förslag?