Utility Types
Prerequisites: Interfaces
TypeScript ships several built-in generic types that transform an existing type into a new one, without redeclaring it from scratch.
interface User {
name: string;
age: number;
email: string;
}
type PartialUser = Partial<User>; // all properties optional
type UserPreview = Pick<User, "name">; // only "name"
type UserNoEmail = Omit<User, "email">; // everything except "email"
type ReadonlyUser = Readonly<User>; // no property can be reassigned
These are especially common when writing a function that only needs
to update some fields of an object (Partial<User>), or expose a
limited public view of a larger internal type (Pick/Omit).