You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/languages/javascript.md
+17-9Lines changed: 17 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ VS Code [IntelliSense](/docs/editor/intellisense.md) is intelligent code complet
21
21
There are two more steps to configure IntelliSense across all the files in your workspace and external modules:
22
22
23
23
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.
@@ -89,25 +89,33 @@ See [here](/docs/languages/jsconfig.md) for the full documentation of `jsconfig.
89
89
90
90
> **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.
91
91
92
-
## TypeScript Definition Files (Typings)
92
+
## Automatic Typings Acquisition
93
93
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.
95
95
96
96
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/).
Typings files are automatically download and managed by Visual Studio Code for packages listed in your project's `package.json`.
101
101
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
+
```
103
107
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`.
105
109
106
-
```bash
107
-
npm install --save-dev @types/lodash
110
+
```json
111
+
"typeAcquisition": {
112
+
"include": [
113
+
"lodash"
114
+
]
115
+
}
108
116
```
109
117
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.
0 commit comments