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