TypeScript Interview
Utility Type Implementation Questions
Re-implement built-in TypeScript utility types from scratch.
Last Updated: July 29, 2026
•
10 min read
Interviewers frequently ask candidates to re-implement TypeScript's standard utility types (${BT}Omit${BT}, ${BT}Exclude${BT}, ${BT}ReturnType${BT}, ${BT}Parameters${BT}, ${BT}NonNullable${BT}) from first principles.
1. Introduction & Architecture
2. Deep Dive & Core Concepts
Implementing built-in utility types builds deep intuition for distributive conditional types and mapped type key remapping (as clause).
3. Basic Code Example
4. Advanced Production Patterns
5. Interactive Code Playground
type MyExclude = T extends U ? never : T;
type T0 = MyExclude<'a' | 'b' | 'c', 'a'>; // 'b' | 'c'
console.log("MyExclude utility type works identically to built-in Exclude.");
6. Common Pitfalls & Edge Cases
Note: Distributive conditional types only distribute over naked type parameters (
T extends U). Wrapping [T] extends [U] disables distribution.7. Interview Q&A & Quizzes
Q: How does key remapping with 'as' work in Mapped Types?
A: The [K in keyof T as NewKey] syntax allows filtering out keys (by returning never) or transforming key names (e.g. using Template Literals).
8. Summary Comparison Table
| Utility Type | Key Mechanism Used |
|---|---|
MyExclude | Distributive Conditional Types |
MyOmit | Mapped Type Key Remapping (as) |
MyReturnType | Function Signature Pattern Matching + infer |