Expressjs: typescript: an argument of type 'typeof <express.Router>' is not assigned to a parameter of type 'RequestHandlerParams'
I am using expressjs with the latest typewriting definition file and typewriting 2.3.4 from https://github.com/DefiniteTyped/DefiniteTyped . I have defined a router and would like to use it from a subpath, as indicated in the official documentation 4.x ( app.use('/calendar', router);), but I get the following error
Error: /Users/matthias/Documents/private workspace/universal/src/server/server.ts (161,34): Argument of type 'typeof "/Users/matthias/Documents/private workspace/universal/src/server/routes/login.router"' is not assignable to parameter of type 'RequestHandlerParams'.
Type 'typeof "/Users/matthias/Documents/private workspace/universal/src/server/routes/login.router"' is not assignable to type '(RequestHandler | ErrorRequestHandler)[]'.
Property 'length' is missing in type 'typeof "/Users/matthias/Documents/private workspace/universal/src/server/routes/login.router"'.
This is the router that I use, skipping the real code ...
const router : express.Router = express.Router();
let loginController = new LoginController();
router.post('/signin', function(req: express.Request, res: express.Response, next: express.NextFunction) {
...
})(req, res, next);
});
...
export default router;
... and this is a shortened version of the appeal to him.
import * as loginRouter from './routes/login.router';
private app = express();
this.app.use('/api/v1/auth', loginRouter);
Am I doing something wrong or is this use case not defined properly in typescript definition files?
Yours faithfully
+5