Type Script Interface: As Object Or Array Type
· 6 min read
Interface in TypeScript can be used to define a type and also to implement it in the class. The most scenarios can be summarized as following:
- as object type definition
- as array type definition
- as function type definition
- interface extends interface
- class implements interface
In this section, we mainly focus on the object and array type definition using interface. As function type definition will be introduced in Function: Types section.
Interface likes contract which defines the structure of the object, array, function and also class. However, we need to note that the TypeScript compiler does not convert interface to JavaScript. It uses interface for type checking.