Skip to content

Commit ae1d417

Browse files
authored
Merge pull request #745 from mjbvz/ata-documentation
Documenting Automatic Typings Acquisition for JavaScript
2 parents 04ac4c7 + 88cf703 commit ae1d417

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

docs/languages/javascript.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ VS Code [IntelliSense](/docs/editor/intellisense.md) is intelligent code complet
2121
There are two more steps to configure IntelliSense across all the files in your workspace and external modules:
2222

2323
1. Create a `jsconfig.json` file to indicate a [JavaScript project](/docs/languages/javascript.md#javascript-project-jsconfigjson).
24-
2. Install [TypeScript Definition files (typings)](/docs/languages/javascript.md#typescript-definition-files-typings) for external libraries.
24+
2. Create a `package.json` file listing dependencies so that [automatic typings acquisition](/docs/languages/javascript.md#automatic-typings-acquisition) kicks in.
2525

2626
![JavaScript intellisense animation](images/javascript/javascript_intellisense.gif)
2727

@@ -89,25 +89,33 @@ See [here](/docs/languages/jsconfig.md) for the full documentation of `jsconfig.
8989

9090
> **Note:** `jsconfig.json` is the same as a `tsconfig.json` file, only with `allowJS` set to true. See [the documentation for `tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) here to see other available options.
9191
92-
## TypeScript Definition Files (Typings)
92+
## Automatic Typings Acquisition
9393

94-
You get VS Code IntelliSense for third-party libraries and modules with type definition `*.d.ts` files. TypeScript definition files are written in TypeScript so they can express the data types of parameters and functions, allowing VS Code to provide a rich IntelliSense experience.
94+
VS Code JavaScript IntelliSense for third-party libraries and modules is powered by type definition `*.d.ts` files. TypeScript definition files are written in TypeScript so they can express the data types of parameters and functions, allowing VS Code to provide rich IntelliSense.
9595

9696
In this image you can see IntelliSense, including the method signature, parameter info, and the method's documentation, for a popular library called [lodash](https://lodash.com/).
9797

9898
![lodash typings](images/javascript/lodash_typings.png)
9999

100-
### Using Typings
100+
Typings files are automatically download and managed by Visual Studio Code for packages listed in your project's `package.json`.
101101

102-
Typings files are installed from the [@types organization on npm](https://www.npmjs.com/%7Etypes).
102+
```json
103+
"dependencies": {
104+
"lodash": "^4.17.0"
105+
}
106+
```
103107

104-
To install the typings for **lodash**, create a [`package.json` file](https://docs.npmjs.com/files/package.json) at the root of your project if one does not already exist, and run:
108+
If you are using Visual Studio Code 1.8+, you can alternately explicitly list packages to acquire typings for in your `jsconfig.json`.
105109

106-
```bash
107-
npm install --save-dev @types/lodash
110+
```json
111+
"typeAcquisition": {
112+
"include": [
113+
"lodash"
114+
]
115+
}
108116
```
109117

110-
This installs the `*.d.ts` type definitions for lodash in order to provide rich IntelliSense. Many common JavaScript libraries have typings avalible. You can learn more about using @types packages [here](https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files/).
118+
Now when you `require` or `import` **lodash**, Visual Studio Code will use the automatically downloaded typings files for the library to provide rich Intellisense. Most common JavaScript libraries have typings available.
111119

112120
## Debugging
113121

0 commit comments

Comments
 (0)