Default configuration
Refers to: #411
Expected Behavior
Default configuration as @default possible so that resolving dependencies is still possible.
Current Behavior
No default configuration with resolving dependencies possible.
Possible Solution
Support @default
Environment
node v14.17.0 Inversify v5.1.1 TypeScript v4.4.4
Description
I think @default is necessary as TypeScript does not really provide needed functionality for default initialization. Example:
@injectable()
Class A implements IA{
constructor(@inject(b) b: IB) // IB: Interface of B
}
@injectable()
Class B implements IB{}
@injectable()
Class C {
@inject (A)
a: IA // Interface of A
}
If you want to achieve default configuratoin in class C and you want to achieve using A as default you still would need to resolve B to construct A. If B is a configuration the client of your package should bind you have no choice as to also let the client bind A which leads to boiler plate configuration.
This is a real use case on developing shared packages which themselfes should use dependency injection internally. Some configurations are needed to be provided by the client, some are basically configurations only needed internally, but still needed to suit open closed principle.
Is there a way to achieve default configuration right now I am missing?
Solutions I tried
The possibility of setting b as a property of A and having an empty constructor in A would leed to the problem that using the package without DI would possible lead to corrupted state of class A as B is not given in A on new A() then.