How to install .d.ts file from github:DefinitelyTypes using typings
Asked Answered
U

3

9

I used tsd which is now deprecated and am trying to use typings. The typings repository is very small, and I can't find any of the d.ts files I need. All the files I need are in GitHub DefinitelyTyped repository, but I can't find a way to install them using typings.

Here is a command I tried:

typings install github:DefinitelyTyped/DefinitelyTyped/angular-formly/angular-formly.d.ts

I receive the error:

typings ERR! message Attempted to compile "angular-formly" as a dependency, 
but it contains some ambient module declarations
("AngularFormly", "angular-formly").

Any clue?

Unprovided answered 4/2, 2016 at 20:7 Comment(0)
R
18

To install angular-formly definitions from DefinitelyTyped, use the following command:

typings install angular-formly --ambient

It's taken directly from here: Quick Start

EDIT: Because this is the accepted answer and syntax has changed, as of typings 1.0:

typings install dt~angular-formly --global
Redskin answered 4/2, 2016 at 20:32 Comment(6)
try it, it does not work - you receive an error message saying "unable to find angular-formly in the registry". If you look at the typings registry, it has only about 30 entries comared with the multiple hundreds in DefinitelyTypes.Unprovided
I have tried it before posting. It does work. Moreover if you check the link it explicitly says that by using --ambient flag you will instruct 'typings' to check definately typed for definitions. Your problem is somewhere else.Redskin
my bad, you are right (I misspelled ambient to ambiant - the problem being french speaking sometimes!)Unprovided
So, what does the ambient flag do that makes it work?Grating
This adds the dependency to the project but apparently you need to instal the dependency manually.... How do you install the dependency manually?Cathern
This adds typescript definitions to the project. Not dependency. If you want to add dependency (whose definitions you had installed with typings) - add it to package.json -> dependencies and then run npm install to fetch it.Redskin
A
13

As of version 1.X of typings the syntax has changed and is now:

typings install dt~angular-formly --global

update: As of typescript 2.0 types are installed using npm: npm install @types/angular-formly

Annulet answered 18/5, 2016 at 12:1 Comment(3)
Thank you! This isn't well-documented across the web. The typings project documented it well, but of all of the tutorials and SO answers I've read, this is the first I've found that mentions this. Crucial. More info: github.com/typings/typings/releases/tag/v1.0.0Boating
Note the tilde: dt<tilde>angular-formlyKistna
I was motivated to attempt to author something comprehensive related to finding / using typings neoheurist.wordpress.com/2016/06/20/definitely-typed comments and feedback welcome/requested - I want it to be as useful / authoritative as possibleGehenna
A
4

I use the following:

./node_modules/.bin/typings install whatever --save --global --source dt

Seems to be the way to do it in v1.3.1.

Anse answered 8/7, 2016 at 16:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.