From the course: Learning TypeScript
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Adding type support for third-party APIs - TypeScript Tutorial
From the course: Learning TypeScript
Adding type support for third-party APIs
- [Instructor] In the previous video, I showed you how to tell Typescript which of the native JavaScript and Dom APIs will be available to your application at runtime, so that it can give you type information about them. In this video, I'll show you how to fix the other set of errors. The ones where Typescript is complaining that it doesn't know about third party libraries like Jquery and view that I've manually imported. The way to give Typescript more information about these libraries, is something called a type declaration, which you can do with the declare keyword, followed by what looks like a normal type declaration, like this. Here I've told Typescript that there is a global variable that it doesn't know about named view, and the type of this global variable is any. As soon as I do this, all of the errors for the view variable go away, since Typescript now at least knows that it exists. The problem is even though…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.