Build a Type Safe Object Keys Helper
Build a generic helper that returns the keys of an object with precise types instead of string[]. Combine keyof, generics, and type assertions for safer iteration and lookup.
Type-safe JavaScript with TypeScript
Build a generic helper that returns the keys of an object with precise types instead of string[]. Combine keyof, generics, and type assertions for safer iteration and lookup.
Avoid the most frequent generic type mistakes in TypeScript. Learn to spot unnecessary type parameters, missing constraints, runtime type checks, and overly complex generics.
A tsconfig.json file tells TypeScript how to compile your project. Learn how to create one, what the key sections mean, and which options to set first.
Conditional types let you write type-level if/else logic that picks different output types based on the input. Learn the syntax, how to constrain generics, and practical patterns.
The infer keyword captures a piece of a type during a conditional check so you can use it in the true branch. Learn how to extract return types, array elements, and promise values.
When a conditional type receives a union, TypeScript distributes the check over each member. Learn how distribution works, when to use it, and how to disable it.
Recursive types reference themselves to describe nested or self-similar structures like trees, linked lists, JSON, and deeply nested arrays or promises.
Branded types add compile-time tags to primitives so TypeScript can tell apart values that share the same underlying type, like UserId and OrderId.
The satisfies operator validates that a value matches a type without changing the value's inferred type. Use it to catch errors while keeping precise type information.
The const modifier on type parameters tells TypeScript to infer the most specific type, like as const but automatic. Added in TypeScript 5.0.
Build a recursive type that makes every nested property readonly. Learn how to combine mapped types, conditional types, and recursion into one reusable utility.
Advanced TypeScript types are powerful but can become unreadable and slow. Learn the warning signs and how to simplify before your types hurt more than they help.