More Utility Types

More Utilities
πŸ‘¨β€πŸ’Ό Excellent! You've mastered the most important utility types.
πŸ¦‰ Key insights:
  • Omit is the opposite of Pickβ€”remove instead of select
  • Required is the opposite of Partialβ€”add instead of remove
  • Exclude/Extract work on unions, not object properties
  • NonNullable is shorthand for Exclude<T, null | undefined>
These utilities compose nicely:
// Remove id, then make everything optional
type UserUpdate = Partial<Omit<User, 'id'>>

// Keep only active statuses, remove null
type ActiveStatus = NonNullable<Exclude<Status, 'deleted'>>

Please set the playground first

Loading "More Utility Types"
Loading "More Utility Types"