TypeScript for Application Developers
LESSON 2.2

Constraints and default type parameters

Learn key techniques and workflows in TypeScript for Application Developers.

4m
intermediate
17,541 students

Overview

Constraints say what a type parameter must at least be. Combined with keyof, they give you property access that stays typed.

In this lesson you will:

  • Constrain a parameter with extends
  • Use keyof to type property access generically
  • Give a type parameter a sensible default

Pro Tip

Use caching and revalidation wisely to ensure your app stays fast and data remains fresh without unnecessary requests.

Resources