typescript - 在 VSCode 中包含 d.ts 类型定义文件

标签 typescript visual-studio-code

我已经开始使用 VSCode 0.7.0 并注意到注释说您不必再添加 /// 引用:

With the introduction of jsconfig.json, you no longer need to use /// references in each file (these were required in the initial versions of VS Code). As the file set is defined in jsconfig.json, VS Code knows what files and symbols are part of your project.

As an example, you can just drop a new type definition .d.ts file into your project folder and VS Code will pick it up automatically.

但是,我在 typings 文件夹中放置了很多这样的文件,而且 VSCode 似乎无法识别它们。有没有人有这方面的经验?

最佳答案

这是我正在使用的 jsconfig.json 文件:

{
    "compilerOptions": {
        "target": "ES6",
        "module": "commonjs",
        "files": [
            "typings/node/node.d.ts"
        ]
    }
}

typings 文件夹位于项目根目录下的 jsconfig.json 文件旁边。

如果您在 nodejs 中突出显示一个未知的全局变量,例如 __dirname 然后点击 cmd+ (ctrl+ . 在 PC 上?)然后选择 下载打字 它们将为您创建。

关于typescript - 在 VSCode 中包含 d.ts 类型定义文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32296299/

相关文章:

iframe - 方法/属性不存在

angular - 如何在Angular4中的同一 View 中使用ngx分页实现多个分页?

javascript - 进度条宽度不动态变化

visual-studio-code - VSCode不显示ColorPicker

powershell - 我们如何在终端中处理 Visual Studio Code 中的问题

TypeScript 2.8.3 类型必须具有返回迭代器的 Symbol.iterator 方法

angular - 在 Angular 2 TypeScript 应用程序中加载 Electron 模块

javascript - 如何在 VS Code 上设置 AngularJS 智能感知

macos - 当我在具有多个显示器的 macOS 中切换桌面时,为什么焦点会切换到另一个意外的应用程序(在我的情况下是 iTerm2 或 VSCode)?

google-chrome - VSCode Chrome 调试器禁用网络安全