-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
For the recent version 4, the redis
package includes TypeScript types but so far only the signatures of createClient()
, commandOptions()
, and createCluster()
are exported (i.e. exported explicitly by name).
This makes it more difficult than necessary to use objects of the "public" types in custom code, such as:
class SomeClass {
// Unable to declare this attribute:
private redisClient: RedisClientType;
}
One workaround is to infer the types from the exported signatures:
// You _can_ get the type like this but this is hard to do for all types:
type RedisClientType = typeof redis.createClient extends () => infer ResultType
? ResultType
: never;
I would suggest that index.ts
should include at least exports of the most common types such as RedisClientType
, RedisClientOptions
, RedisClusterType
, RedisClusterOptions
, TuplesObject
, option types for commands etc.
The only downside to this is that these types now form the public interface of the package API, i.e. may introduce breaking changes if later removed or renamed.