Build types from types
TypeScript ships helpers that transform an existing object type into a related one. They keep a single source of truth so changes flow automatically.
The three workhorses
- Pick selects a subset of keys, producing a type with only those properties.
- Omit is the inverse, removing the listed keys and keeping the rest.
- Partial makes every property optional, useful for update payloads.
Why derive
If you copy a type by hand and the original gains a field, the copy drifts out of date. Deriving with these helpers means a change to the base type updates everything built from it.
Choosing between them
- Reach for Pick when a function needs only a few fields of a record.
- Reach for Omit when you want everything except a sensitive or server set field.
- Reach for Partial when a caller may supply any subset, such as a patch.
Composing them
These helpers nest. You can Omit a key then wrap the result in Partial to model an update that excludes the id and lets every remaining field be optional.
Key idea
Pick, Omit, and Partial derive new shapes from a base type so one definition stays the source of truth.