#Cannot depend on custom provider
11 messages · Page 1 of 1 (latest)
And what does the OperationService's constructor look like?
You need @Inject(Redis.name) because that's the provider name you've told nest about
Not really. That's what it looks like, but under the hood the Redis (class reference) provider nest is trying to inject is actually
class Redis {
<Implementation>
}
we only print the name for the sake of the log. Where as you've told nest about the 'Redis' (string name) provider
Exact same? Or did the error change slightly?
By default, nest uses class implementation references at the injection token. This is a reference to the class's full implementation, in a stringified form, so that there can be Redis from ioredis and Redis from node-redis and they point to different providers. However, once you say provide: Redis.name, that is no longer an implementation reference, but rather a string, so you need to explicitly tell nest @Inject('Redis'). The error message omits the implementation for the sake of brevity in the terminal
I would just do provide: Redis
Because that's how decorators work.. Check the compiled js and see that the Redis class reference actually exists in more than just type
The @Injectable() on the service makes the constructor metadata present even without the @Inject()
Yep
More specifically, that's what the emitDecoratorMetadata option in the tsconfig enables.