Utility Types: Partial Required Pick Omit
Transform existing types with built-in utility types to create variations without duplication.
Utility Types: Partial Required Pick Omit is a free Frontend Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Frontend Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Built-in Utility Types
TypeScript ships with a set of generic utility types that transform other types. They eliminate the need to manually rewrite similar interface variations.
Partial<T>
Makes all properties of T optional. Perfect for update/patch payloads where not all fields need to be provided.
interface User { name: string; email: string; age: number; }
function updateUser(id: string, changes: Partial<User>) {
// changes.name is string | undefined
// changes.email is string | undefined
}
updateUser('1', { name: 'Bob' }); // only update nameRequired<T>
The opposite of Partial — makes all properties required, removing optional (?) modifiers.
interface Config {
host?: string;
port?: number;
debug?: boolean;
}
function validate(config: Required<Config>) {
// All three are now required
console.log(config.host, config.port, config.debug);
}Pick<T, K>
Creates a type with only the specified properties from T. Useful for trimming large objects to only the fields you need.
interface User { id: number; name: string; email: string; password: string; }
type PublicUser = Pick<User, 'id' | 'name' | 'email'>;
// { id: number; name: string; email: string }
// password is excluded — safe to send to clientOmit<T, K>
Creates a type with the specified properties removed. The inverse of Pick.
type UserWithoutPassword = Omit<User, 'password'>;
// { id: number; name: string; email: string }
type CreateUserDto = Omit<User, 'id'>; // new users don't have an id yetReadonly<T>
Makes all properties readonly — prevents reassignment. Useful for configuration objects and immutable data.
const config: Readonly<Config> = {
host: 'localhost',
port: 3000,
};
config.port = 8080; // Error: cannot assign to 'port' because it is read-onlyRecord<K, V>
Creates an object type with keys of type K and values of type V. Cleaner than a raw index signature when keys are a known union.
type Role = 'admin' | 'editor' | 'viewer';
type Permissions = Record<Role, { canEdit: boolean; canDelete: boolean }>;
const perms: Permissions = {
admin: { canEdit: true, canDelete: true },
editor: { canEdit: true, canDelete: false },
viewer: { canEdit: false, canDelete: false },
};ReturnType<T> and Parameters<T>
Extract the return type and parameter types of a function type. Useful when you can't import a type but need to match a function's signature.
function fetchUser(id: number) {
return { id, name: 'Alice' };
}
type UserResult = ReturnType<typeof fetchUser>; // { id: number; name: string }
type FetchParams = Parameters<typeof fetchUser>; // [id: number]Awaited<T>
Unwraps a Promise type to its resolved value type. Useful when working with async functions.
type UserResponse = Awaited<ReturnType<typeof fetchUser>>;
// Resolves both the function return and the Promise
async function load() { return { user: { name: 'Alice' } }; }
type Loaded = Awaited<ReturnType<typeof load>>; // { user: { name: string } }Extract<T, U> and Exclude<T, U>
Extract<T, U> keeps only types in T that are assignable to U. Exclude<T, U> removes them.
type A = 'a' | 'b' | 'c' | 'd';
type BC = Extract<A, 'b' | 'c' | 'e'>; // 'b' | 'c'
type AD = Exclude<A, 'b' | 'c'>; // 'a' | 'd'
// NonNullable removes null and undefined:
type T = string | null | undefined;
type NonNull = NonNullable<T>; // stringComposing Utility Types
Utility types can be composed to create precise types.
type UpdatePayload<T> = Partial<Omit<T, 'id' | 'createdAt'>>;
// Use for PATCH endpoints — omit immutable fields, make rest optional
function patch(id: string, data: UpdatePayload<User>) {
// data can have any subset of mutable user fields
}Quick Check
Which utility type removes specified keys from an interface?
Recap: Utility Types
Partial makes all fields optional. Required removes optional modifiers. Pick keeps selected keys. Omit removes selected keys. Readonly prevents mutation. Record maps union keys to value types. ReturnType and Parameters extract function types. Compose utilities for precise DTO types.
Frequently asked questions
Is the “Utility Types: Partial Required Pick Omit” lesson free?
Yes — the full text of “Utility Types: Partial Required Pick Omit” is free to read here on the web, and the Frontend Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Frontend Academy course, upgrade to CoddyKit PRO.
What will I learn in “Utility Types: Partial Required Pick Omit”?
Transform existing types with built-in utility types to create variations without duplication. You practise Frontend Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Frontend Academy?
No prior experience is required. Frontend Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Utility Types: Partial Required Pick Omit” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Frontend Academy lesson?
Yes. Every Frontend Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Generics: T extends and constraints
- Utility Types: Partial Required Pick Omit
- Mapped Types and Conditional Types
- Narrowing: typeof instanceof discriminated unions