From the course: TypeScript Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Adding type checking to JavaScript files

Adding type checking to JavaScript files - TypeScript Tutorial

From the course: TypeScript Essential Training

Adding type checking to JavaScript files

- [Instructor] At this point, I've now shown you how to add TypeScript to your application and compile TypeScript files. However, one of my favorite things about TypeScript is that it is very easy to add to an existing application with existing JavaScript code. This is because TypeScript is a super set of JavaScript, which means that all JavaScript is valid TypeScript. If you open the exercise folder for this video, you'll see that I've added an example JavaScript file, app.js. To enable checking of existing JavaScript files, I'll simply add two additional settings to my tsconfig.json file. allowJs. And checkJs. And I'll set both of these options to true. Now, I'll run the TypeScript compiler and see what happens. TypeScript found three errors in this new JavaScript file, errors that I planted in order to show how TypeScript can help you, even with JavaScript. I'm actually going to skip this first error: Cannot find…

Contents