Since starting to dive into TypeScript recently, I came across an express server written in TS while browsing the Internet. However, I am struggling to comprehend the type definition of the 'middlewares' argument. Despite attempting to research it in the TypeScript documentation, I have not come across anything similar.
<!-- language: lang-ts -->
function initializeMiddlewares (middlewares: {
forEach: (arg0: (middleware: any) => void) => void
}): void {
middlewares.forEach(middlewares => {
this.app.use(middlewares);
})
}
When I replace it with just 'any' as the type, I ended up with the following code snippet along with an error message:
TS7006: Parameter 'middlewares' implicitly has an 'any' type.
<!-- language: lang-ts -->
function initializeMiddlewares(middlewares: any): void {
middlewares.forEach(middlewares => {
console.log(middlewares)
this.app.use(middlewares);
})
}