-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Add isStrictDi to $injector #11728
Comments
Add a strictDi property which is true or false when creating an instance of an injector. Closes angular#11728
@kentcdodds what is the use case? |
I'm building a tool to validate injectable functions. I would like to know if strictDi is turned on for the injector so I know whether to allow a simple function. |
Here's the beginnings of the tool/lib: https://github.com/alianza-dev/angular-scope-types |
Is this something that you'd ship with the production app, or just something you'd use while developing? |
@btford, the library can be disabled (so it is a no-op for production). But it validates your DDO and I wanted to know whether your DDO should be using explicit annotation based on whether strict di is enabled (which I have enabled in development). But thinking about it further, angular will throw an error if something's not using explicit annotation when it should be so I don't think it's valuable for me to validate that with this library. I'll go ahead and close this. Thanks! |
I'm writing a utility library where I have a use case to know when strict DI is enabled on a given
$injector
. I could really use some reasonable way of knowing without having to do something crazy like:I'm thinking that we could just add a line that says
instanceInjector.strictDi = strictDi
right here before theinstanceInjector
is returned.I would happily open a PR with tests which would do this. Just want to make sure this is the correct approach.
The text was updated successfully, but these errors were encountered: