Sunday, July 4, 2021

TypeScript - Interfaces | Example | demo

TypeScript - Interfaces

 
Interface is a structure that defines the contract in your application. It defines the syntax for classes to follow. Classes that are derived from an interface must follow the structure provided by their interface.
 
The TypeScript compiler does not convert interface to JavaScript. It uses interface for type checking. This is also known as "duck typing" or "structural subtyping".
An interface is defined with the keyword interface and it can include properties and method declarations using a function or an arrow function.

1.Interface as Function Type

2.Interface for Array Type

3.Optional Property

4.Read only Properties


You can see all Example Interface Below Demo








No comments:

Post a Comment

How to build an Express and Node.js app with Typescript

  In this tutorial, you will learn how to set up a Node.js and Express project with Typescript and live auto-reloading. Note that this metho...