I am looking at integrating DI container in to one of my existing nodejs projects. I have integrated awilix and things are working as expected.
However, I am used to typescript and use the type safety in many parts. This is one thing I am not able to get with registering the dependencies using awilix.
e.g. I write the use cases like higher order function
function createReport(specs){
const {reportRepostiory} = specs;
return async (param1: string, param2: string){
//...
reportRepostiory.create({//some payload})
}
}
The calling function calls like
const reportService : any = container.resolve("createReport");
const result = await reportService("1", "2")
The above code works fine with proper container config. However, there is no type inference on the resolved function object. Is there any way to get the types?