问题描述
我有一个具有以下(缩短)结构的项目。
I have a project with the following (shortened) structure.
.
├── 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文件。
所以我没有得到正确的代码完成,快速信息等。
As you can see, I have initialized and installed typings for the project.
However VS Code does not recognize the *.d.ts-files for IntelliSense.
So I do not get properly code completion, quick info etc.
tsconfig.json
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs"
},
"files": [
"typings/index.d.ts"
]
}
jsconfig.json
jsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs"
},
"exclude": [
"node_modules"
]
}
我已经阅读了有关此主题的所有相关博客和问题,但没有找到可行的解决方案。
I have read all related blogs and questions on this topic, but do not came across a working solution.
推荐答案
与此同时(经过数小时的挣扎)我遇到了自己的解决方案。
只需设置编译器在tsconfig.json中选择 allowJs 到 true 并保存。
In the meantime (after hours of struggling) I came across my own solution.
Simply set the compiler option allowJs to true in tsconfig.json and save.
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"allowJs": true
}
}
这是显而易见的根据,它是一个错误,因为它的默认值是正确的。
我在上另外发布了这个问题。
This is obviously a bug because it´s default is true according to the docs.I´ve posted this issue additionally on github.
这篇关于VS Code,打字 - 没有智能感知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!