TSTypeScript · Lesson 7 of 10
Utility Types
TypeScript ships a library of generic utility types that transform existing types. These replace entire categories of repetitive type definitions. Once you know them, you'll wonder how you lived without them.
✦ Tip
Before defining a new interface, ask if a utility type can derive it from an existing one. `Omit<User, "password">` is better than a separate `PublicUser` interface that you have to keep in sync. If the source type changes, derived types update automatically.
Before defining a new interface, ask if a utility type can derive it from an existing one. `Omit<User, "password">` is better than a separate `PublicUser` interface that you have to keep in sync. If the source type changes, derived types update automatically.