Interfaces — TypeScript · Foundations

Describe the shape of an object: required, optional and readonly properties, one interface extending another, methods an object may have, and records with fixed keys. Then see that TypeScript compares shapes, not names.

What you will learn

Read the theory for Interfaces

All TypeScript lessons

All Foundations courses

loading types…

What you'll learn

  • Declare an interface with required, optional and readonly properties, and extend it
  • Describe an optional method and call it only when it is there
  • Explain structural typing: any value with the right shape fits, whatever it is called