Getting Started With TypeScript – Part 9

Hi Friends,

In this section, we will delve further and see how to work with Interfaces using TypeScript. Below, I have created a very simple and straightforward interface and class. Here, class Implements the interface.

And, its equivalent JS code.

With, the above change in place, when I go ahead and run the app, it will produce me the following output. Fairly, straight forward example.

66th

You can also observe, that while writing the code, intellisense is helping you at every stage,

67th

Now, like classes, we can also extend Interfaces as shown below in the snippet. Here, example is very straightforward. You can see for extending interfaces also, I have used extends keyword.

And, its equivalent JS code as shown below.

With the above change in place, it will produce the following output.

68th

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

Thanks,
Rahul Sahay
Happy Coding

691 total views, 2 views today