I am using expressjs with the latest typescript definition file and typescript 2.3.4 from https://github.com/DefinitelyTyped/DefinitelyTyped.
I defined a router and would like to use it from a subpath as is stated in the official 4.x documentation (app.use('/calendar', router);), but I get 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 I am using, ommiting the actual 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 the shortened version of the call to it.
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 usecase just not properly defined in the typescript definition files?
Kind Regards