Generics and type-level tools · mid
Utility types and implementing them
Built-in utilities (Partial, Required, Readonly, Pick, Omit, Record, ReturnType, Parameters, Awaited, NonNullable, Extract, Exclude) are small mapped or conditional types, and interviewers ask you to write them.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Pick<T, K> keeps keys K; Omit<T, K> removes them (Omit is Pick of Exclude of keys).
- Record<K, V> builds an object type with keys K:
Record<Role, Permission[]>forces every role. - Parameters<F> and ReturnType<F> read a function's types; useful to type wrappers.
- Partial is shallow; deep versions need recursion.
- Common senior answer: a form update
(patch: Partial<User>) =>and aPickfor a component's props from a model.
The red pen
Common traps: mistake → fix
Mistake: "Omit is type-safe on keys"
Fix: Omit accepts any string key without error; a stricter version uses
K extends keyof T.Mistake: "Partial is deep"
Fix: it only affects the first level.
Easy to hard
Questions interviewers ask, easy to hard
- Implement Pick and Omit.
- When would you use Record vs an index signature?
- How do you type a function that wraps another and keeps its arguments?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.