Inversify inject decorators return null or error

See original GitHub issue

Expected 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)

  1. Create a container (as in https://github.com/buehler/typescript-hero/blob/develop/src/ioc.ts)
  2. use getDecorators to create the lazy inject decorator
  3. export it with export { lazyInject };
  4. get the error below.

Context

Your Environment

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:open
  • Created 6 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
juanenrisleycommented, Jul 18, 2018

@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.

1reaction
Halynskycommented, Aug 30, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found