Enhancing JavaScript Libraries with TypeScript

Discover how TypeScript leverages existing JavaScript libraries.

Using JavaScript Libraries in TypeScript

One of the most appealing facets of JavaScript development is the wealth of external JavaScript libraries that have already been published, are tried and tested, and are available for reuse. Libraries such as jQuery, Underscore, Backbone, and Moment have been around for years, are well-documented, and can be used to enhance the JavaScript development experience.

As we know, TypeScript generates JavaScript, so we can easily use these libraries and frameworks in TypeScript.

JavaScript is also valid TypeScript, and we can even rename a standard JavaScript file to a TypeScript file just by changing the .js file extension to a .ts file extension if we were converting existing JavaScript files to TypeScript. Remember that the strict typing syntax that is used in TypeScript is entirely optional, and we can, therefore, slowly start to introduce types into a renamed file. The strict typing syntax is also known as syntactic sugar, which can be sprinkled on top of any JavaScript code as and when we please.

Get hands-on with 1200+ tech skills courses.