解决方案是显式地注释路由器变量(TypeScript/issues/5711#issuecomment-161194656).
以下代码将起作用(注意let router: express.Router = express.Router()
)
import * as express from "express"; import * as adminRouter from "./admin/admin"; import * as productRouter from "./products/products"; let router: express.Router = express.Router(); router.use('/products', productRouter); router.use('/admin', adminRouter); // Export the router export = router;