我试图在Microsoft指南之后在Visual Studio代码中设置TypeScript表达/节点应用程序,但是将其更改为使用TypeScript,但是在使用typings我安装类型定义时,我似乎必须安装比指南更多的包.
我正在运行以下一对命令:
typings install node --ambient --save
typings install express --ambient --save
Run Code Online (Sandbox Code Playgroud)
但是,尝试使用这些包进行构建会产生以下类型的错误:
error TS2307: Cannot find module 'serve-static'.
Run Code Online (Sandbox Code Playgroud)
对于以下类型:
我可以通过安装所需的打字来解决这个问题,但似乎某些打字应该自己做.
我想检查一下我是否错过了自动引入依赖关系或者指南是否过时的基本步骤?
如果它是相关的,我的tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"outDir": "bin",
"sourceRoot": "src"
},
"exclude": [
"node_modules",
"typings/browser.d.ts",
"typings/browser"
]
}
Run Code Online (Sandbox Code Playgroud)
我的tsc是1.8.7版本,我在全球范围内安装了打字稿.
我在我的快递应用程序中有以下代码
router.get('/auth/userInfo', this.validateUser, (req, res) => {
res.json(req.user);
});
Run Code Online (Sandbox Code Playgroud)
我的IDE似乎抱怨错误
错误TS2339:"请求"类型中不存在属性"用户".
当我编译我的打字稿代码时,它似乎抛出了这个错误.任何想法为什么会这样?