
Alex Kim
Published November 13, 2025

Master Partial, Pick, Omit, Record, Exclude, Extract, ReturnType, and more — with real-world patterns and best practices.
You don’t need to write every type from scratch.
TypeScript ships with built-in utility types — like Partial<T>, Pick<T, K>, Record<K, T>, and even union manipulators like Exclude<T, U>.
They transform, filter, and compose types with surgical precision.
Let’s go deep. With real-world examples you’ll use every day.
| Utility | What It Does | Use Case |
|---|---|---|
| Partial<T> | Makes all properties optional | Form updates, patch APIs |
| Required<T> | Makes all properties required | Config validation |
| Pick<T, K> | Select specific keys | DTOs, props subsets |
| Omit<T, K> | Remove specific keys | Hide internal fields |
| Record<K, T> | Map keys to type | Dictionaries, lookups |
Partial<T>: Update Without Full Objectinterface User { id: string; name: string; email: string; role: 'admin' | 'user';}function updateUser(id: string, changes: Partial<User>) {// Only update provided fields}Required<T>: Enforce All Fieldsinterface Config { apiUrl?: string; timeout?: number;}const appConfig: Required<Config> = { apiUrl: 'https://api.example.com', timeout: 5000,};Pick<T, K>: Extract What You Needinterface User { id: string; name: string; email: string; password: string;}type PublicUser = Pick<User, 'id' | 'name' | 'email'>;Omit<T, K>: Remove What You Don't Wanttype UserWithoutPassword = Omit<User, 'password'>;// → { id: string; name: string; email: string; }Record<K, T>: Type-Safe Dictionariesconst statusLabels: Record<'pending' | 'success' | 'error', string> = { pending: 'Đang xử lý', success: 'Thành công', error: 'Lỗi',};These work with unions, functions, and classes.
| Utility | What It Does | Use Case |
|---|---|---|
| Exclude<T, U> | Remove U from T union | Filter event types |
| Extract<T, U> | Keep only types assignable to U | Extract string literals |
| NonNullable<T> | Remove null and undefined | API responses |
| ReturnType<T> | Get function return type | Type-safe factories |
| Parameters<T> | Get function parameter tuple | HOC, mocks |
| InstanceType<T> | Get instance type of class | DI, services |
Exclude<T, U>: Filter Out Typestype Event = 'click' | 'hover' | 'scroll' | 'keydown';type MouseEvent = Exclude<Event, 'keydown'>;// → 'click' | 'hover' | 'scroll'Extract<T, U>: Keep Matching Typestype Primitive = string | number | boolean | null;type Truthy = Extract<Primitive, boolean | number | string>;// → string | number | booleanNonNullable<T>: Remove null/undefinedtype ApiResponse = User | null;function processUser(user: NonNullable<ApiResponse>) {// user is guaranteed to be User}ReturnType<T>: Get What a Function Returnsfunction getUser() { return { id: '1', name: 'Alex' };}type UserResult = ReturnType<typeof getUser>;// → { id: string; name: string; }Parameters<T>: Get Function Argsfunction apiCall(url: string, method: 'GET' | 'POST') { }type ApiParams = Parameters<typeof apiCall>;// → [url: string, method: 'GET' | 'POST']InstanceType<T>: Class Instance Typeclass UserService { getUser() { return { name: 'Alex' }; }}type Service = InstanceType<typeof UserService>;// → UserServicetype UserPatch = Partial<Pick<User, 'name' | 'email'>> & { id: string };type Handler = (req: Request) => Promise<Response>;type HandlerParams = Parameters<Handler>;// 1. Manual duplicationinterface UserDTO { id: string; name: string; email: string; }// 2. any for mapsconst cache: any = {};// 3. Wrong Excludetype Bad = Exclude<string | number, string | boolean>;// 1. Reuse with Pick/Omittype UserDTO = Pick<User, 'id' | 'name' | 'email'>;// 2. Record for lookupsconst routes: Record<string, () => void> = {};// 3. Combine for complex typestype UpdatePayload = { id: string } & Partial<User>;Partial<T> → optional propsRequired<T> → all requiredPick<T, K> → select keysOmit<T, K> → remove keysRecord<K, T> → typed mapExclude<T, U> → remove from unionExtract<T, U> → keep from unionNonNullable<T> → remove null/undefinedReturnType<T> → get function returnParameters<T> → get function argsInstanceType<T> → get class instance typeConstructorParameters<T> → get constructor argsUtility types are not shortcuts — they’re leverage.
You’re not just saving lines of code.
You’re eliminating bugs, enforcing contracts, and scaling type safety.
From Partial<Pick<T, K>> to ReturnType<typeof fn>,
every utility is a pattern distilled into a single word.
Master them.
Your types will thank you.
Written by Alex Kim
#TypeScript #UtilityTypes #AdvancedTS #TypeSafety #Exclude #Extract #ReturnType #Pick #Omit #Record #WebDev