In the common construct of defining nested routers in multiple files when exporting a router directly using Typescript 2 and the @types/[email protected] definition following code throws
error TS4023: Exported variable 'router' has or is using name 'Router' from external module
"[...]/node_modules/@types/express-serve-static-core/index" but cannot be named.
Example taken from basarat's answer
import * as express from "express";
// import sub-routers
import * as adminRouter from "./admin/admin";
import * as productRouter from "./products/products";
let router = express.Router();
// mount express paths, any addition middleware can be added as well.
// ex. router.use('/pathway', middleware_function, sub-router);
router.use('/products', productRouter);
router.use('/admin', adminRouter);
// Export the router
export = router;