Lesson overview · Free interview practice

Interfaces

Learn interface definitions and extensions.

Topics in the full lesson
  • Introduction to Interfaces and Type Aliases
  • Defining Object Shapes with Interfaces
  • Function Types in Interfaces
  • Extending Interfaces
  • Implementing Interfaces in Classes
  • Type Aliases
  • Indexable Types and Interfaces
  • Hybrid Types
  • Best Practices
  • Exercises

Practice Problems

Work through a question before revealing its explanation. These questions and answers are free; Premium adds the full lesson walkthrough, examples and implementation detail.

Completion marks record your own progress, not an automatically checked result. The task type does not determine whether it is optional.

TheoryEasy

Optional and `readonly` Properties

Question

How do you mark interface properties as optional or readonly? What's the runtime effect of each?

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

Interface vs Type Alias: Which One When

Question

TypeScript has both interface and type for declaring shapes. What's the practical difference, and when does each one fit?

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

Interface Inheritance with `extends`

Question

How does interface inheritance work in TypeScript? Show single and multiple inheritance, and explain what happens when conflicting properties appear.

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

Declaration Merging: The Interface-Only Superpower

Question

What is declaration merging, and when do you reach for it? Show the canonical use case (extending library types).

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

TheoryMedium

Class Contracts with `implements`

Question

How does the implements keyword work? What does it check, and how does it differ from extends?

Take a moment to think about this before revealing the answer

Explain your reasoning or try an implementation before comparing answers.

Explore the full Interfaces material

Premium includes the complete lessons and implementation references. Free practice questions remain available without a subscription.

All course tracks & premium content
From basics to advanced masterclasses
Built for JS/TS developers like you
Real-world tips & common pitfalls
Upgrade to Premium