What is Interface in TypeScript?

Technology CommunityCategory: TypeScriptWhat is Interface in TypeScript?
VietMX Staff asked 3 years ago

One of TypeScript’s core principles is that type-checking focuses on the shape that values have.

An interface is a virtual structure that only exists within the context of TypeScript. The TypeScript compiler uses interfaces solely for type-checking purposes.

When you define your interface you’re saying that any object (not an instance of a class) given this contract must be an object containing interfaces properties.