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.
You can also observe, that while writing the code, intellisense is helping you at every stage,
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.
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.
761 total views, 1 views today