Dmytro Morar
TypeScript

Interfaces

Interfaces describe the shape of objects and act as type contracts.

Example

interface User {
  name: string;
  age: number;
  email?: string;
}
const user: User = { name: "Olha", age: 28 };

Features

  • Optional and readonly properties.
  • Can describe functions and index signatures.
interface Add {
  (a: number, b: number): number;
}

On this page