在 VSCode 中包含 d.ts 类型定义文件 [英] Including d.ts type definition files in VSCode

查看:45
本文介绍了在 VSCode 中包含 d.ts 类型定义文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've started using VSCode 0.7.0 and noticed the notes say you don't have to add /// references anymore:

随着 jsconfig.json 的引入,您不再需要在每个文件中使用///引用(这些在 VS Code 的初始版本中是必需的).由于文件集在 jsconfig.json 中定义,VS Code 知道哪些文件和符号是您项目的一部分.

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.

举个例子,你可以将一个新的类型定义 .d.ts 文件放到你的项目文件夹中,VS Code 会自动选择它.

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 似乎无法识别它们.有没有人有这方面的经验?

However, I dropped many such files in the typings folder and it doesn't seem VSCode recognizes them. Does anyone have any experience with this?

推荐答案

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

This is the jsconfig.json file I'm using:

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

typings 文件夹与项目根目录下的 jsconfig.json 文件一起存在.

The typings folder exists alongside the jsconfig.json file at the root of the project.

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

If you highlight an unknown global such as __dirname in nodejs then hit cmd+. (ctrl+. on PC?) then select Download typings they will be created for you.

这篇关于在 VSCode 中包含 d.ts 类型定义文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆