Closed remojansen closed 6 years ago
Turns out that this is not an error.
This error may seem a bit misleading because when using classes as service identifiers @inject
annotations should not be required and if we do add an annotation like @inject(Dom)
or @inject(DomUi)
we will still get the same exception. This happens because, at the point in time in which the decorator is invoked, the class has not been declared so the decorator is invoked as @inject(undefined)
. This trigger InversifyJS to think that the annotation was never added. The solution is to use Symbol.for("Dom")
as service identifier instead of the class Dom
.
I have added some test at https://github.com/inversify/inversify-inject-decorators/pull/40/
The following circular dependency graph:
Throws:
However, the following circular dependency graph:
Works:
Source: https://stackoverflow.com/questions/47415313/inversify-circular-singleton-injection/47416198