I have to ask because this is driving me crazy. I see the npm way of installing typings on Google, but Angular2's tutorial has one add a typings.json file then it added the typings folder and downloaded d.ts files from DefinitelyTyped automatically. I tried this with jquery but it didn't download. I also tried rebuilding the project, which I would expect the package.json to include the commands to add additional typings.
Here's my scripts from the package.json file:
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"typings": "typings",
"postinstall": "typings install"
}
Here's the typings.json file I tried. es6-shim and jasmine downloaded.
{ "ambientDependencies": {
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd",
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd",
"jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#7de6c3dd94feaeb21f20054b9f30d5dabc5efabd"
}}
It's probably something simple like not having what appears to be a checksum after the hashtag. Where would I find the correct checksum, or what command do I need to add to package.json to retrieve the typings upon compile, or what am I doing wrong?
Here's another example of adding a line to the typings.json file and then it installs the d.ts files for you. Scroll down until you see Manual Typings
Using only npm (TypeScript 2 and later):
npm install --save @types/jquery
Done: See this for more info.
Using typings (Typescript before v.2):
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
.