Interview Prep
TypeScript
250 questions across 16 categories
50 of 50 questions
| # | Category | Question | Answer | ★ |
|---|---|---|---|---|
| 1 | Type System | What is the difference between 'type' and 'interface' in TypeScript? When should you prefer one over the other? | Click row to expand | |
| 2 | Type System | Explain structural typing (duck typing) in TypeScript. How does it differ from nominal typing? | Click row to expand | |
| 3 | Generics | What are generic constraints? Explain 'extends', 'keyof', and 'infer' in generic constraints. | Click row to expand | |
| 4 | Utility Types | Explain these built-in utility types and implement each from scratch: Partial, Required, Readonly, Pick, Omit, Record. | Click row to expand | |
| 5 | Type Narrowing | Explain TypeScript type narrowing. What are the different narrowing techniques and how does control flow analysis work? | Click row to expand | |
| 6 | Type Narrowing | What are discriminated unions? How do you use them with exhaustive checks and the never type? | Click row to expand | |
| 7 | Advanced Types | What are mapped types? Explain how to use them to create transformation types with modifiers. | Click row to expand | |
| 8 | Advanced Types | What are conditional types? Explain distributivity over unions and how to prevent it. | Click row to expand | |
| 9 | Advanced Types | What are template literal types? Provide practical examples of type-safe string manipulation. | Click row to expand | |
| 10 | Advanced Types | What are recursive types in TypeScript? What are their limitations and how do you handle deeply nested types? | Click row to expand | |
| 11 | Generics | What is variance in generic types? Explain covariance, contravariance, and invariance with TypeScript examples. | Click row to expand | |
| 12 | Generics | Explain higher-kinded types simulation in TypeScript using the HKT pattern. | Click row to expand | |
| 13 | Generics | What is the Awaited<T> utility type? How do you handle deeply nested Promise types? | Click row to expand | |
| 14 | Advanced Types | How do you type a tuple type in TypeScript? What are variadic tuple types and how do they enable type-safe currying? | Click row to expand | |
| 15 | Decorators | What are TypeScript decorators? Explain class, method, property, and parameter decorators. What changes in decorators v2 (Stage 3)? | Click row to expand | |
| 16 | Configuration | Explain the most important tsconfig.json compiler options for strict production TypeScript. | Click row to expand | |
| 17 | Type System | What is the 'unknown' type? How does it differ from 'any', and when should you use it? | Click row to expand | |
| 18 | Type System | What is declaration merging in TypeScript? How is it used for module augmentation? | Click row to expand | |
| 19 | Advanced Types | What is satisfies operator (TypeScript 4.9)? How does it differ from type annotation and 'as'? | Click row to expand | |
| 20 | Advanced Types | Explain the Extract and Exclude utility types. How do you use them to manipulate union types? | Click row to expand | |
| 21 | Type System | What is 'as const' assertion? How does it differ from readonly and how does it enable literal type inference? | Click row to expand | |
| 22 | Configuration | What is the TypeScript project references feature? When and how should you use it for monorepo setups? | Click row to expand | |
| 23 | Type System | What are ambient types and .d.ts files? How do you write type declarations for a JavaScript library that has no types? | Click row to expand | |
| 24 | Generics | How do you implement a type-safe event emitter with generic TypeScript? What pattern enables type-safe event names and payloads? | Click row to expand | |
| 25 | Advanced Types | What is the NoInfer utility type (TypeScript 5.4)? What problem does it solve? | Click row to expand | |
| 26 | Type System | What is excess property checking and when does TypeScript bypass it? | Click row to expand | |
| 27 | Advanced Types | How do you implement a deep merge type in TypeScript? What are the recursive type challenges? | Click row to expand | |
| 28 | Configuration | What are TypeScript path mappings and module resolution? Explain 'node', 'node16', and 'bundler' strategies. | Click row to expand | |
| 29 | Type System | What are opaque/branded types in TypeScript? How do they prevent type confusion between semantically different string or number types? | Click row to expand | |
| 30 | Advanced Types | How do you use TypeScript with React? Explain typing children, event handlers, generics in components, and forwardRef. | Click row to expand | |
| 31 | Type System | What is the 'infer' keyword in conditional types? Provide three advanced use cases. | Click row to expand | |
| 32 | Advanced Types | How do you implement a type-safe builder pattern in TypeScript that ensures required fields are set before build() is called? | Click row to expand | |
| 33 | Type System | What is declaration space and how do types and values coexist in TypeScript? | Click row to expand | |
| 34 | Generics | What is the ReturnType, InstanceType, and Parameters utility types? How do you use them to derive types from existing code? | Click row to expand | |
| 35 | Advanced Types | How does TypeScript handle circular type dependencies? What patterns cause infinite recursion and how do you fix them? | Click row to expand | |
| 36 | Configuration | What is isolatedModules in tsconfig and why is it required by tools like Vite and esbuild? | Click row to expand | |
| 37 | Type System | What are assertion functions in TypeScript? How do they differ from type predicates? | Click row to expand | |
| 38 | Advanced Types | What is the accessor keyword and private class fields (#)? How do they differ from TypeScript's private keyword? | Click row to expand | |
| 39 | Type System | How does TypeScript handle index signatures and Record types? What are the tradeoffs? | Click row to expand | |
| 40 | Generics | What is generic inference from default values and from return types? How does TypeScript infer type parameters from usage context? | Click row to expand | |
| 41 | Type System | What are utility types ReturnType, Awaited, and OmitThisParameter? How do they compose for async method typing? | Click row to expand | |
| 42 | Advanced Types | What is the 'using' keyword and Symbol.dispose (TypeScript 5.2)? How does it improve resource management? | Click row to expand | |
| 43 | Type System | How do you model algebraic data types (ADTs) in TypeScript? Explain product types and sum types. | Click row to expand | |
| 44 | Configuration | What is verbatimModuleSyntax (TypeScript 5.0)? How does it affect import/export behavior? | Click row to expand | |
| 45 | Advanced Types | How do you type a Redux-like state management system in TypeScript with type-safe actions and reducers? | Click row to expand | |
| 46 | Type System | What is module augmentation vs global augmentation? When would you use each? | Click row to expand | |
| 47 | Generics | What is TypeScript's function overloading? When does it help and when does it lead to complexity? | Click row to expand | |
| 48 | Configuration | What is type checking performance? What tsconfig settings and code patterns slow down TypeScript, and how do you fix them? | Click row to expand | |
| 49 | Type System | How do you migrate a large JavaScript codebase to TypeScript? What strategy minimizes disruption? | Click row to expand | |
| 50 | Advanced Types | What is the difference between unknown, never, any, and void in TypeScript? When is each appropriate? | Click row to expand |