Many developers view TypeScript merely as a linter with types. But beneath the surface lies a Turing-complete type system.

Unpacking infer and Recursion

Consider flattening an array type:

type Flatten<T> = T extends Array<infer Item> ? Flatten<Item> : T

type Test = Flatten<[1, [2, [3, [4]]]]> // number

Working through type puzzles forces you to understand variance, distribution, and assignability at a fundamental level.