Codington
0 of 6 problems solved0%

Interfaces

6 exercises

Interfaces describe the shape of an object:

interface User { id: number; name: string; email?: string; // optional readonly created: Date; // can't be changed }

You've already used type aliases. Both type and interface can describe object shapes, and TypeScript cares about structural compatibility: if two shapes match, values can be used interchangeably.

Interfaces offer special features:

  • Extensioninterface Admin extends User { role: string }
  • Declaration merging – Multiple interface declarations combine
  • Index signatures[key: string]: any for flexible keys

In this category, you'll:

  • Define clear object shapes with optional and readonly properties
  • Extend interfaces to build on existing types
  • Use index signatures for dictionary-like objects
  • Merge interface declarations (useful for augmenting libraries)
  • See how interfaces interoperate with type aliases

By the end, you'll know when to use interfaces versus type aliases and how to leverage their unique features.

CodingtonCodington

© 2025 Codington. Built with TypeScript, TanStack Start and a lot of console.log().