Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including d.ts type definition files in VSCode

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

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.

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?

like image 548
Mosho Avatar asked Aug 30 '15 11:08

Mosho


People also ask

What is TS file in VS Code?

TypeScript in Visual Studio Code. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. It offers classes, modules, and interfaces to help you build robust components.

What is file type D TS?

The "d. ts" file is used to provide typescript type information about an API that's written in JavaScript. The idea is that you're using something like jQuery or underscore, an existing javascript library. You want to consume those from your typescript code.


1 Answers

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

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

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

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.

like image 145
homerjam Avatar answered Oct 11 '22 03:10

homerjam