AI Hints
TypeScript · Lesson 93 of 120

Patterns Quiz

Test yourself.

⏱ 2 min read▶ Video at 1:12:16🎓 Free
Watch this lesson in the TypeScript courseWatch on YouTube ↗Full TypeScript course

Let's review the patterns. Pause after each question, and answer before I do.

Patterns Quiz
From the video: Patterns Quiz
  • Patterns quiz
  • Pause and think
  • Then check

Question 1

What does satisfies do? Checks a value, but keeps its exact type.

Quick check
satisfies:

Question 2

What stops two kinds of number ID from mixing? Branded types.

Quick check
Order and customer ids can't mix with:

Question 3

Which method is blocked on a readonly array? Sort.

Quick check
On readonly number[], this is an error:

Question 4

When should you return a result instead of throwing? For expected failures.

Quick check
Use a Result type for:

Summary

Well done. Next, testing with types.

Key takeaways
  • satisfies
  • Brands
  • Result
Next up: Testing with Types — expect errors