javascript - VS Code,打字 - 无 IntelliSense

标签 javascript json visual-studio-code typescript-typings

我有一个具有以下(缩短的)结构的项目。

.
├── 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
  }
}

这显然是一个错误,因为根据 the docs 它的默认值为 true 。 我已将此问题另外发布在 github 上.

关于javascript - VS Code,打字 - 无 IntelliSense,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40224476/

相关文章:

visual-studio-code - 为什么我在linux上找不到vscode live share扩展?

c++ - VS Code 调试控制台输入

javascript - javascript中resolve、reject是关键字吗?

javascript - 按钮不适用于 HTML 和 Javascript

javascript - UglifyJS webpack 插件抛出 : Unexpected token: name (features)

javascript - 我应该如何遍历这个 JSON 数据?

javascript - 这个 typescript forEach 片段有什么作用?

javascript - jquery定位方法

json - 名为 "id"的所有键的输出路径,其中值的类型为 "string"

java - Android GSON - 使用 JSON 结构化对象的模板