← All open source projects

Type Challenges

type-challenges/type-challenges

Type Challenges is a collection of exercises for deeply learning the TypeScript type system with online checks and local play.

Forks 5,262
Language TypeScript
License MIT
Synced 2026-06-10

What it is

Type Challenges is a collection of exercises for the TypeScript type system. It is not a JavaScript logic problem set, but a trainer for type-level programming: conditional types, infer, mapped types, tuple operations, unions, type recursion, and compiler constraints. The project helps developers understand how to write robust type utilities and read complex library definitions.

The repository appeared in 2020 and became popular because TypeScript in large projects has moved far beyond annotating variables. Complex types shape component APIs, routers, data schemas, validators, and SDKs. Type Challenges provides a safe place to study those ideas through small exercises.

What is inside

Challenges are grouped by difficulty and can be played through the TypeScript Playground, a VS Code extension, or locally. An important detail is that challenges run in strict mode, so solutions must satisfy the stricter type model. The repository also includes recommended readings, articles, talks, and links to solutions.

What a challenge looks like

This example shows the exercise style: implement a type so compile-time tests pass without running JavaScript code.

Language: TypeScript
type MyPick<T, K extends keyof T> = {
  [P in K]: T[P];
};

type Todo = { title: string; done: boolean; count: number };
type Preview = MyPick<Todo, "title" | "done">;

Where it is useful

Type Challenges is useful for developers who write libraries, design systems, SDKs, complex React/Vue components, or want to read TypeScript errors with more confidence. It trains a kind of thinking that ordinary application work does not always build.

Limitations

The natural risk is overdoing type puzzles and making production code too clever. A good product solution is not always the most sophisticated one. Type Challenges is best used as a training ground for understanding, not as a reason to turn every type into metaprogramming.