Built-in Utility Types
TypeScript includes powerful built-in utility types that transform existing types. Partial makes all properties optional, Pick selects specific properties, Omit excludes them, and Record creates key-value map types. Mastering these eliminates repetitive type definitions.
40 min•By Priygop Team•Last updated: Feb 2026
Essential Utility Types
Example
// Source type
interface User {
id: number;
name: string;
email: string;
age: number;
role: "admin" | "editor" | "viewer";
}
// Partial<T> — All properties optional
type UpdateUserDto = Partial<User>;
// { id?: number; name?: string; email?: string; ... }
function updateUser(id: number, updates: Partial<User>): User {
// Only update provided fields
return { ...existingUser, ...updates };
}
updateUser(1, { name: "New Name" }); // Only name is required
// Required<T> — All properties required
type RequiredUser = Required<User>;
// Pick<T, K> — Select specific properties
type UserPreview = Pick<User, "id" | "name" | "role">;
// { id: number; name: string; role: "admin" | "editor" | "viewer" }
// Omit<T, K> — Exclude specific properties
type CreateUserDto = Omit<User, "id">;
// { name: string; email: string; age: number; role: ... }
// Record<K, V> — Create key-value map type
type UserRoles = Record<string, User>;
const users: UserRoles = {
alice: { id: 1, name: "Alice", email: "a@test.com", age: 25, role: "admin" },
};
type StatusCounts = Record<User["role"], number>;
// { admin: number; editor: number; viewer: number }
// Readonly<T> — All properties readonly
type FrozenUser = Readonly<User>;
// All properties are readonly — cannot be reassigned
// Extract & Exclude — filter union types
type AdminOrEditor = Extract<User["role"], "admin" | "editor">;
// "admin" | "editor"
type NotAdmin = Exclude<User["role"], "admin">;
// "editor" | "viewer"
// ReturnType<T> — Get function return type
function createUser() { return { id: 1, name: "Alice" }; }
type NewUser = ReturnType<typeof createUser>;
// { id: number; name: string }
// Parameters<T> — Get function parameter types
type CreateUserParams = Parameters<typeof createUser>;
// []
// NonNullable<T> — Remove null and undefined
type MaybeString = string | null | undefined;
type DefiniteString = NonNullable<MaybeString>; // string