Topics

Jump to a topic.

Search questions

Find a question by title, tag, or summary.

Chapter 02

Inference and narrowing

How the compiler infers types and narrows them through control flow: type guards, discriminated unions, satisfies, and assertions.
6 questions
  1. 010How does TypeScript infer types, and when should you annotate explicitly?Coming soonmedium
  2. 020How does narrowing work, and what built-in checks narrow a type?Coming soonCoremedium
  3. 030How do you write a user-defined type guard or assertion function?Coming soonmedium
  4. 040What is a discriminated union, and how do you check it exhaustively?Coming soonCoremedium
  5. 050What does satisfies do, and how is it different from a type annotation?Coming soonmedium
  6. 060What do as, !, and !: actually do, and when are they safe?Coming sooneasy