Problem Statement
Compose Omit, Pick, Partial, Readonly to shape DTOs for an update endpoint.
Explanation
Readonly prevents accidental changes on read models; Pick/Omit selects allowed fields; Partial makes them optional for updates. Result: strict, self-documenting DTOs that block unwanted properties at compile time.
Code Solution
SolutionRead Only
type User = { id: string; name: string; email: string; role: 'admin'|'user' };
// client reads
type UserView = Readonly<Pick<User, 'id'|'name'|'email'>>;
// client updates (only allowed fields, all optional)
type UserUpdate = Partial<Pick<User, 'name'|'email'>>;