As I work on developing my app, I have decided to implement the dependency-injection pattern. In passing mongoose and config libraries as parameters, I encountered an issue with the config library. Specifically, when hovering over config.get('dbUri'), an error message pops up saying: 'Untyped function calls may not accept type arguments.ts(2347)'
app.ts
(async () => await initializeDatabaseConnection(mongoose, config))();
connect.ts
async function initializeDatabaseConnection(mongoose: any, config: any):Promise<void>{
try {
const dbUri = config.get<string>('dbUri');
await mongoose.connect(dbUri, () => {
console.log('connected to the database successfully!');
});
} catch (error) {
process.exit(1)
}
}
export default initializeDatabaseConnection;