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?
Typings was just a tool to install those files. It is now best practice to just use npm. When you have installed those files, which basically only means downloading them and placing them in your project, the TypeScript compiler will understand* that external code and you will be able to use those libraries.
d. ts is the type definition files that allow to use existing JavaScript code in TypeScript. declare function sum(a: number, b: number): number; From now on, we can use the function in TypeScript without any compile errors.
*. d. ts files are used to provide typescript type information about a module that's written in JavaScript, for example, underscore / lodash / aws-sdk. This will allow you to use the javascript modules without the need to convert them to ts without getting any type of error on your code.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With