Open XaeroDegreaz opened 4 years ago
Almost the same here. Same version of typescript-ioc.
import { Get, Route } from "tsoa";
import { Inject, Singleton } from "typescript-ioc";
@Singleton
class Katana {
public hit() {
return "cut!";
}
}
@Singleton
class Shuriken {
public throw() {
return "hit!";
}
}
@Singleton
@Route('/ninja')
export class NinjaController {
private _katana: Katana;
private _shuriken: Shuriken;
constructor(@Inject katana: Katana, @Inject shuriken: Shuriken) {
this._katana = katana;
this._shuriken = shuriken;
}
@Get('/fight')
public fight() { return this._katana.hit(); };
@Get('/sneak')
public sneak() { return this._shuriken.throw(); };
}
"typescript-ioc": "^3.2.2"
I've tried several variations of the constructor including a simple
@Inject connectionManager: ConnectionManager
to no avail. I've also tried field injection, and that didn't work, but I suspect that information wouldn't be available in the constructor anyhow.If I add a constructor in
TileRepository
and@Inject
theConnectionManager
, then pass it tosuper()
it will work, but I don't want to lead that implementation detail.