-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
If it is intentional that the useExisting async option should resolve to a factory instance, This does not align with the (current documentation)[https://docs.nestjs.com/fundamentals/custom-providers#alias-providers-useexisting]. I believe this would lead to unnecessary complexity that should be solved using Injected tokens in a useFactory provider instead.
It aligns with every custom
useExisting
implementation (for configuring dynamic modules) we had in the ecosystem before the configurable module class was introduced.This is the expected behavior.
useExisting
represents an existing configuration factory provider, not the configuration itself.
Originally posted by @kamilmysliwiec in #15013
I still think the use of useExisting
assumes an InjectionToken, not a Factory, according to its use in packages/core/injector/module.ts
This is also supported by the (useExisting)[https://docs.nestjs.com/fundamentals/custom-providers#alias-providers-useexisting] documentation, which describes a provider of an instance (in this case a class function), not a "factory" for the instance.
I have searched for a while for documentation to support your claim, and I don't want to start an argument, especially as your name is against much of this code, however I still believe my assessment has credence, in the least for the sake of clearer documentation describing this behaviour.