Utility Type (TypeScript)
Utility types are built-in generic types that transform other types, such as `Partial<T>`, `Pick<T, K>`, `Omit<T, K>`, and `Record<K, V>`. They save you from rewriting common type transformations.
TypeScript
TypeScript ships these helpers globally, so you can reuse a base type in many shapes. `Partial<T>` makes every property optional, `Pick` keeps only chosen keys, `Omit` removes keys, and `Record` builds an object type from keys to a value type.
Most utility types are implemented as mapped types, so once you understand mapped types you can read or even write your own.
Syntax
Partial<T>, Pick<T, K>, Omit<T, K>, Record<K, V>Examples
TypeScript
interface User { name: string; age: number; }
type Draft = Partial<User>; // both optional
type NameOnly = Pick<User, "name">;
const d: Draft = {};
const n: NameOnly = { name: "Ana" };
console.log(n.name);Output:
Ana