Getting Started with TypeScript – Part 10

Hi Friends,

In this section, we will see how to use third party libraries like jquery or angular or anything with TypeScript. TypeScript, provides this flexibility to use any third party libraries on the top of your TS file, using some interface. And, this interface is called Definitely Typed in TypeScript.  Here, is the URL of Definitely Typed http://definitelytyped.org/Once you open the same, it will open the following page.

69th

Here, when you click on >_TSD link, you will land on http://definitelytyped.org/tsd/.

70th

Here, when you search for the desired library, it will list the desired file, which you can then download from here and add the same in project.

71th

Similarly, I also need Toastr library as shown below.

72nd

Now, let me show the files, which I have included from the portal.

73rd

Now, Toastr file has a dependency on Jquery file, hence, In that toastr file, I have added the reference of Jquery at the top as shown below in the screenshot.

74th

After, that I have modified my script as shown below in the snippet.

And, it’s equivalent JS looks like

Now, after including third part library in the TS file, you can get the intellisense of that library as well as shown below in the screenshot.

75th

Apart from this, I have also modified the HTML file to fix the Jquery dependency and other CSS stuffs like shown below.

With the above change in place, it will produce the result

76th

I hope, you would have liked this discussion. Thanks for Joining me. We’ll continue delve further. Till then stay tuned and Happy Coding.

Thanks,
Rahul Sahay
Happy Coding