"TypeScript's constructor assignments" as stated here is not working.
Expected Behavior
No errors are thrown.
Current Behavior
Throws Error: Missing required @inject or @multiInject annotation in: argument 0 in class Ninja.
Possible Solution
With @inject decorator, everything works perfectly.
Steps to Reproduce (for bugs)
import 'reflect-metadata';
import { Container, injectable } from 'inversify';
@injectable()
class Ninja {
public constructor(private _dagger:Dagger) {}
public throwDagger() {
this._dagger.throw();
}
}
@injectable()
class Dagger {
public throw() {
console.log('throw dagger');
}
}
const container = new Container();
container.bind<Ninja>(Ninja).toSelf();
container.bind<Dagger>(Dagger).toSelf();
container.get(Ninja).throwDagger();
Context
N/A
Your Environment
Version used: 6.0.2
Environment name and version (e.g. Chrome 39, node.js 5.4): Node.js 18.19.0
Operating System and version (desktop or mobile): macOS 14.2.1
Link to your project: N/A
Stack trace
Error: Missing required @inject or @multiInject annotation in: argument 0 in class Ninja.
at getConstructorArgsAsTarget (/xxx/node_modules/inversify/lib/planning/reflection_utils.js:78:19)
at getConstructorArgsAsTargets (/xxx/node_modules/inversify/lib/planning/reflection_utils.js:90:22)
at getTargets (/xxx/node_modules/inversify/lib/planning/reflection_utils.js:56:30)
at getDependencies (/xxx/node_modules/inversify/lib/planning/reflection_utils.js:41:12)
at /xxx/node_modules/inversify/lib/planning/planner.js:124:71
at Array.forEach (<anonymous>)
at _createSubRequests (/xxx/node_modules/inversify/lib/planning/planner.js:112:20)
at plan (/xxx/node_modules/inversify/lib/planning/planner.js:154:9)
at /xxx/node_modules/inversify/lib/container/container.js:626:46
at Container._get (/xxx/node_modules/inversify/lib/container/container.js:596:38)
"TypeScript's constructor assignments" as stated here is not working.
Expected Behavior
No errors are thrown.
Current Behavior
Throws
Error: Missing required @inject or @multiInject annotation in: argument 0 in class Ninja.
Possible Solution
With
@inject
decorator, everything works perfectly.Steps to Reproduce (for bugs)
Context
N/A
Your Environment
Stack trace