2

I used to work with tsd for managing my type definitions, but as it's deprecated, I'm trying to migrate to typings which is my opinion more complicated, but should be the way to go, I guess.

I want to install a type definition and for that I use the --ambient flag.

In Visual Studio I have the typings.json file which looks like that:

{
  "name": "Test",
  "version": false,
  "ambientDependencies": {
    "angular": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular.d.ts#ca92a5b250433c38230b5f4138b36453862342bf",
    "jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#ca92a5b250433c38230b5f4138b36453862342bf"
  }
}

This was automatically created when migrating from tsd to typings but now once I need a new type definition, for instance angular-route I use the following command:

typings install angular-route --ambient

This works fine, but the typings.json does not get updated.

What is the point and why am I missing? Why were angular and jquery both migrated to typings.json and when installing angular-routethe file does not get refreshed?

3 Answers 3

20

Actually in Typings 1.0 they did some breaking changes. "ambient" is now "global". Just in case, installing from DefinitelyTyped must be explicit.

The following will install jQuery and save it to typings.json

typings install dt~jquery --global --save

See the link in Igor's answer for more info

1
  • Thanks for posting this, the documentation on how to use the sources is confusing
    – cgatian
    Jun 1, 2016 at 17:43
5

You forgot --save

typings install angular-route --ambient --save

command syntax above is now obsolete and only applicable to version 0.x

Link to Typings command help


Update

As pointed out by @AndresM there are breaking changes in going from version 0.x to 1.x. See the documentation Updating From 0.x to 1.0?. The command syntax in @AndresM answer is the correct way to execute a typings command using DefinitelyTyped store and Typings version 1.x.

1
  • 1
    SWEET! That is what I was missing indeed and I was pretty sure I also tried this before, but yes. I think I was way too long struggling with that. thanks
    – DAG
    Mar 16, 2016 at 16:15
3

Now with Typescript2.0(https://blogs.msdn.microsoft.com/typescript/2016/09/22/announcing-typescript-2-0/) the global is also gone. The following will install jQuery and angular typings:

npm install --save @types/angular @types/jquery

Your package.json will then have:

"dependencies": {
  "@types/angular": "^1.5.16",
  "@types/jquery": "^2.0.33"
}

Your node_modules directory will have @types/angular and @types/jquery directories which contain index.d.ts files.

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.