Step1
创建一个jsconfig.json
文件来指示 VS Code 中的 JavaScript 项目,只需转到 VS Code 底部并单击绿色灯泡图标。
它会要求你创建jsconfig.json
。创造jsconfig.json
文件,其中将包含以下代码。
//jsconfig.json
{
// See https://go.microsoft.com/fwlink/?LinkId=759670
// for the documentation about the jsconfig.json format
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules",
"bower_components",
"jspm_packages",
"tmp",
"temp"
]
}
Step2
Install typings globally for downloading TypeScript Definition files (typings) for node modules like express, mongoose, angular etc.
npm install typings --global
TypeScript 定义文件是用 TypeScript 编写的,旨在为函数及其参数提供 VS IntelliSense 体验。让我们安装 Express 的类型,如下所示:
typings insall dt~express --global
让我们尝试一下express的编码体验。您将看到出色的 Express 智能感知功能。