One of the most appealing facets of JavaScript development is the myriad of external JavaScript libraries that have already been published, such as jQuery, Knockout, and Underscore. The TypeScript designers knew that introducing "syntactic sugar" to the TypeScript language would bring a range of benefits to the developer experience. These benefits include IDE features such as Intellisense, as well as detailed compile time error messages. We have already seen how to use this syntax for most of the TypeScript language features such as classes, interfaces, and generics, but how do we apply this "sugar" to existing JavaScript libraries? The answer is relatively simple—declaration files.
A declaration file is a special type of file used by the TypeScript compiler. It is marked with a .d.ts
extension, and is then used by the TypeScript compiler within the compilation step. Declaration files are similar to header files used in other languages; they...