【发布时间】:2018-10-03 18:55:42
【问题描述】:
我正在运行 tsc --watch(将 typescript 编译成 javascript)并捕获警告:
router/PostRouter.ts(103,16): error TS2503: Cannot find namespace 'postRoutes'.
在我的 .ts 文件中的 103 字符串中:
const postRoutes = new PostRouter();
postRoutes.routes();
export default postRoutes.router;
那么,怎么了?
我的 package.json 文件:
{
"name": "typescript-express-server",
"version": "1.0.0",
"main": "./build/index.js",
"license": "MIT",
"scripts": {
"start:server": "nodemon --watch ./build/index.js",
"watch:build": "tsc --watch"
},
"dependencies": {
"bcrypt-nodejs": "0.0.3",
"body-parser": "1.18.2",
"compression": "1.7.2",
"cookie-parser": "1.4.3",
"cors": "2.8.4",
"dotenv": "5.0.1",
"express": "4.16.3",
"helmet": "3.12.0",
"lodash": "4.17.5",
"mongoose": "5.0.15",
"morgan": "1.9.0"
},
"devDependencies": {
"@types/body-parser": "1.16.8",
"@types/cookie-parser": "1.4.1",
"@types/cors": "2.8.4",
"@types/express": "4.11.1",
"@types/mongoose": "4.7.32",
"@types/node": "9.6.6",
"nodemon": "1.17.3",
"tslint": "5.9.1",
"typescript": "2.8.3"
}
}
【问题讨论】:
-
@AluanHaddad 谢谢!
标签: node.js typescript tsc