I wanted to use redis client with promisify
:
import type { RedisClient } from "redis";
import * as util from "util";
class MyClass {
private redisClient: RedisClient;
constructor(client: RedisClient) {
this.redisClient = client;
}
getMyData = (): SomeType[] => {
const getAsync: Promise<string | undefined> = util.promisify(this.redisClient.get).bind(this.redisClient);
// ...
};
}
However I ran into two issues with eslint:
ESLint: Avoid referencing unbound methods which may cause unintentional scoping of 'this'.(@typescript-eslint/unbound-method)
atthis.redisClient.get
fragment
and
ESLint: Unsafe assignment of an any value.(@typescript-eslint/no-unsafe-assignment)
atgetAsync
How I can use promisify
in a way that will be type aware and proper this
scoping?