← TypeScript learning path
TypeScript · Module 8 of 10

Utility types and enums

Use built-in helpers to transform types.

📖 Key ideas

  1. Partial<T> makes all properties optional.
  2. Required<T>, Readonly<T>, Pick<T, K>, Omit<T, K>.
  3. Record<K, V> builds object types.
  4. ReturnType<typeof fn> gets a function's return type.
  5. Enums name constants; union of literals is often simpler.
💡 Real-life example: Utility types are cookie cutters: reshape an existing dough (type) instead of making a new one.
PartialAll properties optional
PickKeep chosen properties
OmitRemove chosen properties
enumNamed set of constants