Better type solution

This commit is contained in:
Jeremy Rifkin
2022-12-27 18:52:36 -07:00
parent 2b0d0e7700
commit 9deaffbb7c
+7 -2
View File
@@ -49,8 +49,13 @@ export class StorageRemote extends StorageBase {
baseUrl: this.baseUrl,
});
this.get = promisify(req.get as any as (uri: string, options?: request.CoreOptions) => request.Response);
this.post = promisify(req.post as any as (uri: string, options?: request.CoreOptions) => request.Response);
// Workaround for ts type shenanigans with defaulting to the last overload
this.get = promisify((uri: string, options?: request.CoreOptions, callback?: request.RequestCallback) =>
req.get(uri, options, callback),
);
this.post = promisify((uri: string, options?: request.CoreOptions, callback?: request.RequestCallback) =>
req.post(uri, options, callback),
);
}
override async handler(req: express.Request, res: express.Response) {