Skip to content

Still insist this is looked into, createAsyncOptionsProvider implmentation error #15014

@coderatchet

Description

@coderatchet

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

Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions