Q27. What are utility types?
Utility types are built-in type transformations such as Partial, Required, Pick, Omit, Record, Readonly, Exclude, Extract, ReturnType, and NonNullable. They help derive related contracts and reduce duplication, but only affect compile-time types.
Use Pick and Omit to shape API DTOs; use Partial for patch input where partial updates are valid.
Note
Interview approach: define the concept, explain why it matters, then mention one trade-off or limitation.
TypeScript concept
// Illustrative TypeScript contract
type Identifier = string;
const id: Identifier = "item-1";💡 The example demonstrates the compile-time contract discussed in this question.
Key Takeaways
- Explain the concept in your own words.
- Know the practical trade-off and its limits.
- Use a small example to demonstrate the idea.
Knowledge Check
Which utility type makes properties optional?