Working with Interfaces in Typescript

In our last article, we discussed how to work with Enums, functions and anonymous functions. In this article, we will discuss about Interfaces in Typescript.

Interface

One of TypeScript’s core principles is that type-checking focuses on the shape that values have. This is sometimes called “duck typing” or “structural subtyping”. In TypeScript, interfaces fill the role of naming these types, and are a powerful way of defining contracts within your code as well as contracts with code outside of your project.

Type interference to actual types

Now our existing function we discussed in previous post will become from this

To this

Here is the complete video of the above discussion

You can find the complete code from here in GitHub

Thanks for reading the post and watching the video!!!

Please leave your comments and let me know if there is anything I should update in this post.

Thanks,
Karthik KK

Leave a Reply

Your email address will not be published. Required fields are marked *