Hello guys. I need to use inversifyjs for my game.
I got it working well with cocos 3.3.1
but when i try to use decorator in class constructor, i got error showing : SyntaxError: illegal character U+0040
it seems like the @ in constructor consider as illegal character.
is there any reference to configure the decorator to work in constructor parameter?
here is the example of code that cause the SyntaxError
@injectable()
class Katana {
public hit() {
return "cut!";
}
}
@injectable()
class Shuriken {
public throw() {
return "hit!";
}
}
@injectable()
class Ninja {
private katana!: Katana;
private shuriken!: Shuriken;
constructor(
@inject(Katana) katana: Katana,
@inject(Shuriken) shuriken: Shuriken
) {
this.katana = katana;
this.shuriken = shuriken;
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.throw(); };
}
and here is the example of workaround and using property injection instead of constructor injection
@injectable()
class Katana {
public hit() {
return "cut!";
}
}
@injectable()
class Shuriken {
public throw() {
return "hit!";
}
}
@injectable()
class Ninja {
@inject(Katana) private katana!: Katana;
@inject(Shuriken) private shuriken!: Shuriken;
constructor(
) {
}
public fight() { return this.katana.hit(); };
public sneak() { return this.shuriken.throw(); };
}
please help me to solve this, i really want to use constructor injection.
Thank you guys