← TypeScript for Beginners

Lesson 2 of 3 · 10 min

Interfaces & objects

An interface describes an object's shape: interface Student { name: string; grade: number }.

Optional fields use a question mark: nickname?: string.

Practice

Define a Book interface with title, author and an optional rating.

Quiz

+50 pts
1. An interface describes…
2. Optional fields use…

Optional resources

Your lesson toolkit

No purchase or partner signup is required to complete this course or earn quiz points.

These are official product links, not active affiliate links. Learnly does not currently earn a commission from them.

TypeScript Playground

Experiment with types and see compiler feedback instantly.

Free browser tool.

Explore tool