You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 24, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 24, 2026. It is now read-only.
src/index.ts:19:4 - error TS7017: Element implicitly has an 'any' type because type 'Express' has no index signature. 19 app[route.method](route.path, (request: Request, response: Response, next: Function) => { ~~~~~~~~~~~~~~~~~
Is there a way to combine modules in this elegant way and enable strict?
Well, this is awkward. Just started getting into typeorm today, really liking it, stumbled upon this question, tried the first solution that came to my mind and it worked! In case anyone will still find it useful I'll leave it here 🤓
The solution is to type AppRoutes as an array of Route. That Route interface has to look like this:
This way you tell typescript exactly what strings to expect in that method key, hence it does not think it is viable for an invalid key to pop up there. I omitted the last argument for the action (next) on purpose, but do add it if you want it there!
Activity
mrnkr commentedon Sep 1, 2019
Well, this is awkward. Just started getting into typeorm today, really liking it, stumbled upon this question, tried the first solution that came to my mind and it worked! In case anyone will still find it useful I'll leave it here 🤓
The solution is to type
AppRoutesas an array ofRoute. ThatRouteinterface has to look like this:This way you tell typescript exactly what strings to expect in that method key, hence it does not think it is viable for an invalid key to pop up there. I omitted the last argument for the action (
next) on purpose, but do add it if you want it there!Again, hope this helps someone! Happy coding!
ScottWallace commentedon Aug 14, 2020
That is a wonderfully elegant piece of code, but it needs middleware, especially authentication middleware. Here's how to do it:
Add an element to the path objects that need authentication in the
routes.tsfile, called "secure". Not every element needs it.Now use this code in place of your standard
AppRoutes.forEach:You should replace
firebaseService.authenticationMiddleware()with whatever middleware you want to provide.Fun!