我有一个具有以下(缩短的)结构的项目。
.
├── app
│ ├── app.css
│ ├── app.js
│ └── home
│ ├── home.css
│ ├── home.html
│ └── home.js
├── jsconfig.json
├── package.json
├── tsconfig.json
├── typings
│ ├── globals
│ │ ├── jquery
│ │ │ ├── index.d.ts
│ │ │ └── typings.json
│ │ └── office-js
│ │ ├── index.d.ts
│ │ └── typings.json
│ └── index.d.ts
└── typings.json
如您所见,我已经初始化并安装了该项目的类型。
但是 VS Code 无法识别用于 IntelliSense 的 *.d.ts 文件。
所以我没有得到正确的代码完成、快速信息等。
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs"
},
"files": [
"typings/index.d.ts"
]
}
jsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs"
},
"exclude": [
"node_modules"
]
}
我已阅读有关此主题的所有相关博客和问题,但没有找到有效的解决方案。
最佳答案
与此同时(经过几个小时的努力)我找到了自己的解决方案。
只需在 tsconfig.json 中将编译器选项 allowJs 设置为 true 并保存即可。
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"allowJs": true
}
}
关于javascript - VS Code,打字 - 无 IntelliSense,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40224476/