Chapter 7. Using TypeScript and JavaScript in the same project

 

This chapter covers

  • Enjoying TypeScript’s benefits when working with a JavaScript library
  • The role of type definition files
  • Upgrading an existing JavaScript app to TypeScript

In this chapter, we’ll show how you can benefit from TypeScript features such as getting compilation errors and autocomplete even while using third-party libraries written in JavaScript. We’ll start by explaining the role of type definition files, and then we’ll discuss a concrete use case where an app written in TypeScript uses a JavaScript library. Finally, we’ll discuss the things you should consider before implementing a gradual upgrade of your app from JavaScript to TypeScript.

7.1. Type definition files

The JavaScript language was created in 1995, and gazillions of lines of code have been written in this language since then. Developers from around the globe have released thousands of libraries written in JavaScript, and the chances are that your TypeScript app could benefit from using one of these libraries.

7.2. A sample TypeScript app that uses JavaScript libraries

7.3. Introducing TypeScript in your JavaScript project

Summary

sitemap