Skip to main content
PProfileMatch
← Path

TypeScript · TypeScript Interfaces, Type Aliases and Union Types

0 XP
  1. 1 current stop: learning
  2. 2 upcoming
  3. 3 upcoming
  4. 4 upcoming
  5. 5 upcoming

Finish after stop 5

Stop 1 of 5 · Help desk: the ticket form

Trick to keep in mind+3 XP

A ? property is a drawer that might be empty: look before you use it

An optional property may be absent from the object entirely. Reading it yields the property's type plus undefined, so you cannot assign it to a variable of the plain type until you have handled the missing case. If a field must always exist, leave off the ?.

Read it once, then a question tests whether the trick stuck.