Essential TypeScript Utility Types for Beginners
Published: 2025-11-27T10:32:28.596Z
TypeScript provides a powerful set of built-in utility types that help you transform existing types without rewriting them. These utilities make your code more flexible, readable, and safer.
This guide explains the most commonly used ones with very simple examples.
1. Object Shape Utilities
These utilities help modify the structure of object types.
Partial
Makes all properties optional.
type User = { name: string; age: number }
type PartialUser = Partial<User>
// PartialUser -> { name?: string; age?: number }
Required
Makes all properties required, even if they were originally optional.
type User = { name?: string; age?: number }
type StrictUser = Required<User>
// StrictUser -> { name: string; age: number }
Readonly
Makes all properties read-only and prevents reassignment.
type User = { name: string; age: number }
type ImmutableUser = Readonly<User>
Pick
Creates a new type by selecting specific properties from an existing one.
type User = { name: string; age: number; email: string }
type UserPreview = Pick<User, 'name' | 'email'>
Omit
Creates a new type by removing specific properties.
type User = { name: string; age: number; password: string }
type PublicUser = Omit<User, 'password'>
Record
Creates a type with a set of keys and a defined type for values.
type Roles = 'admin' | 'user'
type RolePermissions = Record<Roles, number>
// { admin: number; user: number }
2. Union Modification Utilities
These utilities help work with union types.
Exclude
Removes one or more types from a union.
type Status = 'loading' | 'success' | 'error'
type WithoutLoading = Exclude<Status, 'loading'>
Extract
Keeps only the matching types from a union.
type Status = 'loading' | 'success' | 'error'
type OnlySuccess = Extract<Status, 'success'>
NotNullable
Removes null and undefined from a type.
type Value = string | null | undefined
type CleanValue = NotNullable<Value>
// string
3. Function and Constructor Utilities
These types extract information related to functions.
ReturnType
Gets the return type of a function.
function getAge() {
return 25
}
type Age = ReturnType<typeof getAge>
// number
Parameters
Gives a tuple of all parameter types of a function.
function createUser(name: string, age: number) {}
type UserArgs = Parameters<typeof createUser>
// [string, number]
ConstructorParameters
Extracts parameter types of a class constructor.
class Person {
constructor(name: string, age: number) {}
}
type PersonArgs = ConstructorParameters<typeof Person>
// [string, number]
4. Async-Related Utility
Awaited
Extracts the resolved type of a promise.
type ApiResponse = Promise<string>
type Result = Awaited<ApiResponse>
// string
Works for nested promises as well:
type Nested = Promise<Promise<number>>
type Output = Awaited<Nested>
// number
5. String Manipulation Types
These are compile-time helpers for transforming string literal types.
Uppercase, Lowercase, Capitalize, Uncapitalize
type Name = "fayaz"type A = Uppercase<Name> // "FAYAZ"
type B = Lowercase<Name> // "fayaz"
type C = Capitalize<Name> // "Fayaz"
type D = Uncapitalize<"Hello"> // "hello"
These are useful when building API response keys, CSS variable names, or template literal types.
Final Thoughts
TypeScript’s utility types save time by allowing you to transform types instead of writing new ones from scratch. Once you start using them regularly, your codebase becomes cleaner, safer, and more expressive.