Pages

Topics

Tools

↑↓navigate↵openescclose

TypeScript guides

Every published TypeScript guide, newest first, with practical examples you can copy into your own project.

3,815 guides across 14 topics

Topics

Latest TypeScript guides

3D illustration contrasting a hazardous red open any conduit with a secure blue unknown chamber guarded by verification gates
TypeScript

TypeScript unknown vs any: Type Safety, Type Guards, and Best Practices

Why any contaminates every caller while unknown forces the check at the boundary, with validation functions, generic inference traps, and the few places any is honestly correct.

TypeScriptType SafetyBest Practices
3D illustration of JavaScript object key tags being scanned into a type-safe union key ring labelled with property names
TypeScript

TypeScript keyof and typeof: Object Type Queries and Property Keys

The difference between the two type queries, why keyof typeof collapses to string without literal types, and how K extends keyof T keeps a key and its value type in correspondence.

TypeScriptType SystemGenerics
3D illustration of a nested generic promise capsule being scanned by a glowing infer sensor that extracts the resolved inner type
TypeScript

TypeScript infer Keyword: Conditional Types, ReturnType, and Unwrapping

How infer binds a type inside a conditional type, why distribution over unions changes results, and how ReturnType, Parameters, and recursive unwrapping types are actually built.

TypeScriptGenericsAdvanced
3D illustration of mutable TypeScript variable boxes locking into frozen crystalline readonly type blocks with glowing padlocks
TypeScript

TypeScript as const: Const Assertions, Readonly Tuples, and Literal Types

What as const actually changes in inference, why object properties widen without it, and how readonly tuples, derived unions, and satisfies combine in real config and route tables.

TypeScriptType SystemWeb Development
A glowing ring wrapping a method module and routing metadata conduits
TypeScript

TypeScript Decorators: Stage 3 Syntax, Method Decorators, and Metadata

The standard decorator pipeline since TypeScript 5.0: the value and context signature for methods, fields, and accessors, addInitializer ordering, Symbol.metadata, and where it diverges from experimentalDecorators.

TypeScriptDecoratorsArchitecture
Glowing letter blocks assembling into a type-safe string pattern with neon brackets
TypeScript

TypeScript Template Literal Types: Syntax, String Manipulation, and Patterns

Template literal types as patterns over string types: union cross products, the four intrinsic case types, key remapping with as, infer-based splitting, and the depth limit that ends recursive types.

TypeScriptType SystemAdvanced
Modular type blocks locking into constrained keyof slots with glowing alignment lines
TypeScript

TypeScript Generics: Type Constraints, extends Keyof, and Default Types

What T extends really constrains, how K extends keyof T keeps a return type tied to the key you pass, defaults on type parameters, and where NoInfer stops a second argument from widening inference.

TypeScriptGenericsType System
Union type values funneled through type guard gates into separate Admin, Guest, and null streams
TypeScript

TypeScript Type Narrowing: Type Guards, in Operator, and Discriminated Unions

Every guard TypeScript uses to narrow a union, what each one removes, and the three failures that keep narrowing from applying: typeof null, widened discriminants, and closures over mutable bindings.

TypeScriptType SystemWeb Development
Modular TypeScript type blocks being picked, omitted, and assembled into a Record
TypeScript

TypeScript Utility Types: Pick, Omit, Partial, and Record Explained

How Pick, Omit, Partial, and Record are built from mapped types: what each preserves, why Omit accepts a typo, how Partial distributes over unions, and the errors each raises.

TypeScriptGenericsUtility Types
TypeScript satisfies operator validating a config object against a type while keeping literal types
TypeScript

TypeScript satisfies Operator: Syntax, vs Type Annotations, and as const

How the TypeScript 4.9 satisfies operator validates an expression without widening its inferred type, why per-property types survive, and how as const changes the result.

TypeScriptType SystemWeb Development