When you use an interface (I assume that Weapon
is an interface) you need to ensure that the same ID is used when you declare the binding:
container.bind<Weapon>(Shuriken).toSelf();
And then you declare the injection:
@injectable()
class SomeClass {
public constructor(
@inject(Shuriken) weapon: Weapon; // Use the right ID!
) {
However, using the class removes the benefits of dependency injection. If you want you to use classes you could actually do something more simple:
@injectable()
class SomeClass {
public constructor(
weapon: Shuriken; // Use the class as Type!
) {
The recommended solution is to use strings or symbols as IDs:
const TYPE = { Weapon: "Weapon" };
container.bind<Weapon>(TYPE.Weapon).to(Shuriken);
@injectable()
class SomeClass {
public constructor(
@inject(TYPE.Weapon) weapon: Weapon;
) {