TypeScript interview warm-up

Generics, discriminated unions, utility types and what types do (not) do at runtime.

  1. Type Assertions Don't Convert `as number` changes the type, not the value. Easy TypeScript
  2. readonly and as const at Runtime Compile-time immutability doesn't freeze objects. Medium TypeScript
  3. Numeric Enums at Runtime Auto-incremented values and reverse mappings of TypeScript enums. Medium TypeScript
  4. Type-safe groupBy<T, K>() Write a generic groupBy that infers key and item types. Easy TypeScript
  5. Result Type Instead of Exceptions Model success/failure with a discriminated union and narrow on it. Medium TypeScript
  6. Typed pick() and omit() Implement runtime pick/omit whose return types match Pick<T,K> and Omit<T,K>. Easy TypeScript
  7. Two Sum Find the indices of the two numbers that add up to a target. Easy Most asked All 5 languages
  8. Flatten Nested JSON Turn nested objects and arrays into a flat map with dotted keys. Medium All 5 languages
  9. LRU Cache A fixed-capacity cache that evicts the least recently used key, with O(1) get and put. Medium Most asked All 5 languages

← All coding problems