Using definition files

There are a number of ways to include definition files within your project. When TypeScript was initially released, the only way to include definition files was to download them manually from DefinitelyTyped, store them into a directory within your project, and then reference them manually. As the popularity of TypeScript started increasing, so did the number of definition files, and thus finding and installing the correct files became more difficult. Several tools then started to emerge to aid with this process. The first of these was a Node-based command-line tool named tsd, which allowed for querying the DefinitelyTyped database, and installing the relevant definition files. tsd was deprecated in early 2016, in favour of another tool named Typings. Typings also allowed for querying and installing definition files based on the DefinitelyTyped database. One of the major features of Typings was the ability to target a specific version of a definition file, and to store the relevant information in a configuration file named typings.json.

With the release of TypeScript 2.0, the ability to install type definition files was folded into the popular npm package, and thus didn't require any other tools for managing definition files. If you are using Node, npm, and a package.json file, then npm has all of the features required to include definition files in your project.

If you are working with the Visual Studio or WebMatrix IDEs, then you can use NuGet to accomplish the same thing. In this section of the chapter, we will explore both the NuGet and npm methods of managing definition files.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.15.59.163