What are utility types in TypeScript like Partial, Pick and Omit?
Quick answer
Utility types are built-in helpers that transform an existing type: Partial makes every field optional, Required the opposite, Pick keeps a set of keys, Omit removes them, and Record builds a key/value map.
Partial<User> is useful for a PATCH body. Pick<User, "id" | "name"> is a list-row type. Omit<User, "password"> is what you send to the client. Record<Id, User> is a dictionary. ReturnType<typeof fn> and Parameters<typeof fn> pull types from functions so you do not repeat them.
You can write the same things with mapped types; the utilities are the readable version. Interviews sometimes ask you to implement Partial yourself: { [K in keyof T]?: T[K] }.
type User = { id: string; name: string; password: string };
type PublicUser = Omit<User, "password">;
type UserPatch = Partial<Pick<User, "name" | "password">>;