Open marwankhalili opened 1 year ago
We are changing the command options API in v5, which removes the CommanOptions<T>
type, but anyway, just move the @redis/client
from dependencies
to peerDependencies
in your utility project, and don't lock it to a specific version (this way you'll be able to install the utility package + whatever version of @redis/client
you need).
Cool I hope this can be resolved in v5!
I tried the peerDependencies
-route initially (first code example) but the problem is that I'm working on a monorepo. Relying on @redis/client
being hoisted won't work since various versions of the library is used across services.
I published an example repository to illustrate this: https://github.com/marwankhalili/redis-utility-example
packages/service-a
installs redis@4.6.6
-> @redis/client@1.5.7
packages/service-b
installs redis@4.6.5
-> @redis/client@1.5.6
Rethinking this, the root issue might be that redis
has specified exact versions of internal @redis
libraries:
I believe this issue could be resolved if the caret (^) semver range specifier was used instead, but perhaps there's a reason why that isn't being used?
Description
Hi!
I'm trying to write a utility package for my microservices. Part of the abstraction is related to data stored in Redis‚ so I thought my utility package could reuse the microservice's client connection:
This utility package worked fine in one microservice, but caused a TypeScript error in another. I noticed the problem occurs when the internal
@redis/client
version differs between the utility package and the microservice.Minimal reproducible example:
package.json:
The TypeScript compatibility issue is partially due to the "private" class fields in the declaration files (see https://github.com/microsoft/TypeScript/issues/18499) but also due to the unique symbol used in
CommandOptions<T>
. The example above only works if I remove both from the declaration files of@redis/client
.Node Redis Version
4.6.6