You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
InversifyJS allows your classes to have a direct dependency on other classes. When doing so you will need to use the @Injectable decorator but you will not be required to use the @Inject decorator.
Error: Missing required @inject or @multiInject annotation in: argument 0 in class Ninja.
This error is mentioned in the same document as part of the Known Limitation: Classes as identifiers and circular dependencies, but without any circular dependencies it happens as well.
Possible Solution
Using @Inject decorator on constructor parameters makes it work.
Steps to Reproduce (for bugs)
Create a node project using npm init -y
Install typescript and correctly configure it using npx tsc --init and inversify documentation
Install inversify and reflect-metadata
Create a typescript test file with the following code
Environment name and version (e.g. Chrome 39, node.js 5.4): node v20.17.0
Operating System and version (desktop or mobile): MacBook
Link to your project:
Stack trace
Error: Missing required @Inject or @multiInject annotation in: argument 0 in class Ninja.
at getConstructorArgsAsTarget (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/reflection_utils.js:78:19)
at getConstructorArgsAsTargets (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/reflection_utils.js:90:22)
at getTargets (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/reflection_utils.js:56:30)
at getDependencies (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/reflection_utils.js:41:12)
at /Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/planner.js:124:71
at Array.forEach ()
at _createSubRequests (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/planner.js:112:20)
at plan (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/planner.js:154:9)
at /Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/container/container.js:626:46
at Container._get (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/container/container.js:596:38)
The text was updated successfully, but these errors were encountered:
Expected Behavior
InversifyJS allows your classes to have a direct dependency on other classes. When doing so you will need to use the @Injectable decorator but you will not be required to use the @Inject decorator.
Current Behavior
When following the code here: https://github.com/inversify/InversifyJS/blob/master/wiki/classes_as_id.md, class that has direct dependencies on other classes cannot be create, error occurred:
Error: Missing required @inject or @multiInject annotation in: argument 0 in class Ninja.
This error is mentioned in the same document as part of the Known Limitation: Classes as identifiers and circular dependencies, but without any circular dependencies it happens as well.
Possible Solution
Using @Inject decorator on constructor parameters makes it work.
Steps to Reproduce (for bugs)
npm init -y
npx tsc --init
and inversify documentationinversify
andreflect-metadata
npx tsx your test file
Context
Don't know what's going wrong, basically using the example from here: https://github.com/inversify/InversifyJS/blob/master/wiki/classes_as_id.md, but doesn't work.
Your Environment
inversify@6.0.2
typescript@5.6.2
Stack trace
Error: Missing required @Inject or @multiInject annotation in: argument 0 in class Ninja.
at getConstructorArgsAsTarget (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/reflection_utils.js:78:19)
at getConstructorArgsAsTargets (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/reflection_utils.js:90:22)
at getTargets (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/reflection_utils.js:56:30)
at getDependencies (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/reflection_utils.js:41:12)
at /Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/planner.js:124:71
at Array.forEach ()
at _createSubRequests (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/planner.js:112:20)
at plan (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/planning/planner.js:154:9)
at /Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/container/container.js:626:46
at Container._get (/Users/han/Documents/workspaces/temp/inversify-test/node_modules/inversify/lib/container/container.js:596:38)
The text was updated successfully, but these errors were encountered: