One of the most appealing facets of JavaScript development is the wealth of external JavaScript libraries that have already been published, such as jQuery, Knockout, Underscore, Lodash, or Moment. As we know, TypeScript generates JavaScript, so we can easily use JavaScript libraries in TypeScript. We have already seen how TypeScript uses syntactic sugar to enhance our JavaScript development experience by providing a strong typing mechanism. If we are using JavaScript libraries, however, how do we apply this sugar to existing JavaScript or 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...