help wantedtyping
Description
Consider a function to remove a single key/array of keys:
public async removeKeys(keys: string | string[]): Promise<void> {
this.redis.del(keys);
}
This currently gives a type error on the .del function since it cannot accept a union of string or string[].
I would expect that there is no type error since the code above simply works. Either passing a single key or an array of keys gives the correct result.
The current workaround is forcing the string to be an array, but that's weird to cast here just for typing.
public async removeKeys(keys: string | string[]): Promise<void> {
keys = Array.isArray(userIds) ? userIds : [userIds]; // Needs explicit conversion here
this.redis.del(keys);
}
What do you think? Is this the intended behavior or could we loosen/improve the typing here?