Flashcard Deck · 21 cards · Public

TypeScript & Advanced Type Systems - Generics, Utility Types & Design Patterns

Master advanced TypeScript mechanics including Generics, Utility Types, Conditional Types, Mapped Types, and Type Narrowing. Designed for engineering interview prep and building bulletproof software architectures.

Cards in this deck

(21 cards)

Preview terms and definitions before starting your study session.

#1
Term
Generic Constraints (extends)
Definition
Constrains a generic type parameter to guarantee it implements a specific structure or extends a specific type. Syntax: function logLength<T extends { length: number }>(arg: T): T. Passing a type without a .length property triggers a compile-time error.
#2
Term
Partial<T> Utility Type
Definition
Constructs a type with all properties of T set to optional (?). Implemented under the hood using a mapped type: type Partial<T> = { [P in keyof T]?: T[P]; }.
#3
Term
Required<T> vs. Readonly<T>
Definition
Required<T> removes optional modifiers (-?) from all properties of T, making them mandatory. Readonly<T> prepends the readonly modifier to all properties, preventing reassignment after initialization.
#4
Term
Pick<T, K> Utility Type
Definition
Constructs a type by extracting a specific subset of property keys K from object type T (where K extends keyof T). Example: type UserSummary = Pick<User, 'id' | 'email'>;.
#5
Term
Omit<T, K> Utility Type
Definition
Constructs a type by taking all properties from T and dropping the specified keys K. Equivalent to Pick<T, Exclude<keyof T, K>>. Example: type UserWithoutPassword = Omit<User, 'password'>;.
#6
Term
Record<K, T> Utility Type
Definition
Constructs an object type whose keys are of type K (which must extend keyof any, i.e., string | number | symbol) and whose property values are of type T. Example: Record<string, User> maps arbitrary string keys to User objects.
#7
Term
Exclude<T, U> vs. Extract<T, U>
Definition
Exclude<T, U> removes types from union T that are assignable to U. Extract<T, U> selects types from union T that are assignable to U. Both utilize distributive conditional types.
#8
Term
ReturnType<T> & Parameters<T>
Definition
ReturnType<T> extracts the return type of a function type T. Parameters<T> extracts a tuple type containing all parameter types of function type T. Both use conditional types and the infer keyword.
Showing 8 of 21 cards in this deck.
Study All Now