From the course: TypeScript Essential Training

Unlock the full course today

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

Defining global types with ambient modules

Defining global types with ambient modules - TypeScript Tutorial

From the course: TypeScript Essential Training

Defining global types with ambient modules

- [Instructor] In the imports and exports video, I showed you how to convert an existing application that relied on global functions, to modules using imports and exports. However, if you have a large existing codebase that relies on global imports for existing JavaScript files that can't be converted, don't lose hope. In this video, I'll show you how to document that JavaScript code, so you can continue to use those dependencies without a problem. To begin, I'll go back to the same application that I just converted, back to before I converted it. Remember this was the version of the application that was explicitly loading all of the JavaScript files. I'll start out by converting the app.js file to TypeScript, just like last time, and I'll see that error again. TypeScript doesn't know about a function named formatDate, just like last time. However, in order to fix this problem this time, I'm going to create my own version…

Contents