I am dynamically creating a nest js service class:
const generatedClass = {
[className]: class { ... }
}[className]
I wish to mimic the usual function of
@Injectable()
export class MyService { }
And as such, I am doing:
const generatedClass = {
[className]: class { constructor(private dep1: Dep1...) {} }
}[className]
Injectable()(generatedClass)
to mimic the decorator registering the class. However, when doing this, the service does not seem to get reigstered with the DI container, and when I inject this service, it doesn't seem to resolve the dependencies in the constructor.
The service seems to inject correctly, but it does not resolve the dependencies inside the service, leaving me quite confused. Is it possible to call Injectable manually or am I missing some steps?