How do you type a pipe() function that takes an infinite number of functions, where the output of function A must perfectly match the input of function B? Welcome to the final boss of TypeScript.
Learn how to build chainable APIs that accumulate type knowledge at every step. This Generic Accumulator pattern is the secret engine powering libraries like tRPC, Zod, and Prisma, providing unparalleled autocomplete.
TypeScript doesn’t care if two types have different names; if they share the same shape, they are equivalent. Learn how to use Branding and Flavoring to force the compiler to differentiate between an OrderID string and a UserID string, powering Domain-Driven Design.
Why is it safe to return a subclass instead of a superclass, but dangerous to accept a superclass parameter instead of a subclass? Welcome to Variance: the computer science underpinning of TypeScript’s assignability engine.
Use mapped types and generics to enforce finite state transitions in the compiler. A type-level state machine makes impossible states impossible to represent, eliminating entire classes of runtime bugs.
The built-in Partial and Readonly utilities are shallow. Learn how to write your own DeepReadonly and DeepPartial utilities that penetrate every layer of nested objects by combining Generics, Conditionals, infer, Mapped Types, and Recursion simultaneously.
TypeScript provides four built-in Intrinsic utilities that manipulate the casing of string literal types at compile time. Learn how to pair them with template literals and mapped types to dynamically generate robust event handler mappings.
Template literal types allow you to use JavaScript-style template strings (${...}) inside Type Space. Learn how to generate combinations of string literals automatically via Union Permutation, and parse delimited strings (like emails or URLs) using the infer keyword.
Pattern matching with infer isn’t just for Promises and Objects. You can deconstruct Tuples and Arrays element by element in Type Space, mirroring the exact syntax of JavaScript’s array destructuring and spread operators.
Learn how the built-in Awaited<T> utility models the runtime await keyword. We explore how to combine the infer keyword with Recursive Type Aliases to drill down and unwrap Promises infinitely deep, and how to compose it with ReturnType for async functions.