Closed remojansen closed 8 years ago
Hi @otbe and @endel, since you asked me about this issue in the past I would appreciate your input on this. You can follow the progress here.
Thanks!
I have implemented this at https://github.com/inversify/InversifyJS/pull/333
Current Behavior
In some cases when working with derived classes we get an error:
This error is correct and was designed to prevent users from forgetting to inject all the required arguments into a Base class. However, in some cases the code is correct and no error should be thrown. The issue is caused because the container cannot find out how many arguments have been injected by the users (as opposed to be injected by the container).
Steps to Reproduce
Expected Behavior
There should be a way to allow users to inject some of the arguments into the derived class and not get the error. So we have two kinds of arguments injected into a base class:
Because InversifyJS does not have control under user provided values and it doesn't manage their injection I though that a good name for a new annotation would be
@unsafe()
or@unmanaged()
. For the moment I'm using@unmanaged()
but I'm open to sugestions.Possible Solution
We can use the
@unmanaged()
annotation to flag the arguments that will be not managed by the container, or in other words, the values that will be injected by the an user:We should support cases with multiple args:
If you forget the
@unmanaged()
annotation an error will be thrown just like in the current implementationContext
This issue has been reported many times so It is a high priority issue.