Inversify inject decorators return null or error
See original GitHub issueExpected Behavior
lazyInject should be a usable decorator, instead it’s just null or undefined or something else 😦
Somehow this gets thrown away.
Steps to Reproduce (for bugs)
- Create a container (as in https://github.com/buehler/typescript-hero/blob/develop/src/ioc.ts)
- use
getDecoratorsto create the lazy inject decorator - export it with
export { lazyInject }; - get the error below.
Context
Your Environment
- Version used: 4.9.0 with inversify inject decorators 3.1.0
- Environment name and version (e.g. Chrome 39, node.js 5.4): VSCode Extension
- Operating System and version (desktop or mobile): macOS
- Link to your project: https://github.com/buehler/typescript-hero/blob/develop/src/ioc.ts
Stack trace
Here is the error stack: TypeError: ioc_1.lazyInject is not a function
extensionHostProcess.js:292
at Object.<anonymous> (/Users/christoph/Documents/Development/typescript-hero/out/src/declarations/workspace-declarations.js:24:11)
at Object.<anonymous> (/Users/christoph/Documents/Development/typescript-hero/out/src/declarations/workspace-declarations.js:29:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Function.J.X.t.getExtensionPathIndex.then.o._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/node/extensionHostProcess.js:490:709)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Inversify inject decorators return null or error - Bountysource
lazyInject should be a usable decorator, instead it's just null or undefined or something else :-( Somehow this gets thrown away.
Read more >inversify/InversifyJS - Gitter
I currently struggle to debug an "Error: NULL argument at Lookup.hasKey". Any recommendation how to do that? I inject a class instance into...
Read more >Inversify cannot inject class with dependencies - Stack Overflow
You are struggling because the react babel config does not allow decorators, so what you can do is:
Read more >Dependency injection: setting up InversifyJS IoC for Typescript ...
After the container is set up the dependencies can be made injectable by importing injectable decorator from inversify and decorating classes ...
Read more >Dependency injection or IOC | tsoa - GitHub Pages
If you want to use dependency injection and let the DI-framework handle the creation ... import { buildProviderModule } from "inversify-binding-decorators"; ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@remojansen Hi! I am facing the same problem. I have two modules, let’s call them A and B. Module A exports all classes that I want to be injected and module B exports the inversify configuration (container initialization, bindings declaration and decorators creation). I think that the problem comes with circular dependency. Module A is imported in module B to declare the bindings and module A imports the lazyInject decorator from module B, then the error occurs.
I had a similar issue because lazyInject was exported from my configuration after it was used in service. So that’s why it was undefined in runtime.