How does one add a typing to typings.json for Typescript in Visual Studio 2015?
- Make sure you have npm installed
- Open up your console of choice (e.g. command prompt or powershell)
- Navigate to your project folder
Using only npm (TypeScript 2 and later):
npm install --save @types/jquery
Done: See this for more info.
Using typings (Typescript before v.2):
- Make sure you have typings installed, if not run
npm install typings --global
Write
typings install dt~jquery --save --global
This should update your typings.json file and download the definition files.
In the above example for typings, 'dt~' means that it should look for jquery in the DefinitelyTyped repository, the default is 'npm'. The syntax has changed slightly from version 0.x to 1.0, the flag
--global
was previously--ambient
.
I found that opening and resaving package.json once the typings.json file had been created triggered the typings to pull down. This is my current typings file:
{ "ambientDependencies": { "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd", "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd" }}