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 of structural primitive strings receiving holographic brand stamps that prevent cross-assignment
TypeScript

TypeScript Branded Types: Nominal Typing, Type Tags, and Validation

How a phantom property makes two strings incompatible, unique symbol brands, unit-typed numbers, and the places where a brand quietly disappears.

TypeScriptNominal TypingType Safety
3D illustration of generic parameter slots filling with default type blocks when no type arguments are supplied
TypeScript

TypeScript Generic Parameter Defaults: Syntax, Precedence, and Inference

When a default applies and when inference wins, defaults that reference earlier parameters, and how a defaulted type parameter keeps a library change non-breaking.

TypeScriptGenericsType Inference
3D illustration of a transparent blueprint declaration wireframe overlaying untyped JavaScript runtime machinery
TypeScript

TypeScript Ambient Declarations: .d.ts Files, declare, and declare global

How declare and .d.ts files describe runtime values, wildcard modules for assets, declare global with var, and module augmentation of third-party types.

TypeScriptDeclaration FilesTooling
3D illustration contrasting legacy namespace domes with modern modular ES import/export pipelines
TypeScript

TypeScript Namespaces vs Modules: Syntax, Declaration Merging, and Use Cases

How namespace merging works across files, why isolatedModules rejects it, and a migration path to ES modules with barrels and export * as.

TypeScriptArchitectureModules
3D illustration of type assertion overrides casting ambiguous variable silhouettes into validated concrete type forms
TypeScript

TypeScript Type Assertions: as Syntax, Non-Null Assertion, and Safety

What an assertion actually promises, when the compiler rejects one, how as unknown as T bypasses the check, and where ! hides a lifecycle bug.

TypeScriptType SafetySyntax
3D illustration of bracket-indexed selectors plucking property type cubes from a nested object matrix
TypeScript

TypeScript Indexed Access Types: Syntax, Lookup Types, and Arrays

T[K] lookups on objects, arrays, and tuples, the undefined that optional properties add, and recursive path types built on indexed access.

TypeScriptGenericsType Queries
3D illustration of multiple call signature input slots channeling into a unified implementation engine
TypeScript

TypeScript Function Overloads: Syntax, Signatures, and Implementation

Overload resolution order, why the implementation signature is invisible to callers, the union-argument rejection, and when a generic signature is shorter.

TypeScriptFunctionsType System
3D illustration of tagged union data blocks branching into exhaustive switch cases with a secure never-type barrier
TypeScript

TypeScript Discriminated Unions: Exhaustiveness Checking and the never Type

Why the discriminant must be a literal, how never closes an exhaustive switch, and the duplicate-discriminant bug that lets a missing case compile.

TypeScriptType NarrowingPattern Matching
3D illustration of glowing numeric step counters and string literal blocks being organized into an immutable enum registry
TypeScript

TypeScript Enums: Numeric, String, const Enums, and Alternatives

How each enum form compiles, why numeric enums emit a reverse mapping, what const enums cost under per-file transpilation, and how an as const object replaces them.

TypeScriptType SystemEnums
3D illustration of a transformer pipeline converting object keys into prefixed getter methods with glowing neon gears
TypeScript

TypeScript Mapped Types: Syntax, Key Remapping with as, and Modifiers

How mapped types iterate over keys, add and remove readonly and optional modifiers, and use the as clause to rename keys or drop properties entirely with never.

TypeScriptGenericsUtility Types