TypeScript

28 cheat sheets.

28/28

TypeScript Project References

Split a TypeScript codebase into composite sub-projects, build them incrementally in dependency order with tsc --build, and integrate the result with bundlers, Turborepo, and Nx.

05-25-2026#typescript#build#monorepo

TypeScript Modules

Deep dive into TypeScript's module system — module/moduleResolution pairs, .mts/.cts file extensions, NodeNext vs Bundler resolution, paths, and tsconfig extends.

05-25-2026#typescript#modules#esm

TypeScript Compiler API

Drive the TypeScript compiler programmatically — parse SourceFiles, query the type checker, transform ASTs with the factory, and write codemods that scale across a monorepo.

05-25-2026#typescript#tooling#advanced

typeof & keyof

TypeScript's typeof promotes a runtime value into the type position; keyof extracts the union of property keys. Together they form the backbone of type-safe lookups, enum-from-object patterns, and inferred shapes.

05-25-2026#typescript#types#operators

type-fest

Sindre Sorhus's collection of essential TypeScript utility types — PartialDeep, ReadonlyDeep, SetOptional, RequireAtLeastOne, Merge, Tagged, JsonValue, Opaque, and dozens more — so you don't hand-roll them.

05-25-2026#typescript#library#utility-types

ts-node, tsx & Friends

Compare ts-node, tsx, Node 22.6+ --experimental-strip-types, Bun, and Deno for running .ts files directly; pick the right tool, configure watch mode, and avoid the classic ESM / type-strip pitfalls.

05-25-2026#typescript#runtime#tooling

Template Literal Types

Template literal types let TypeScript pattern-match and synthesize string types — covering Uppercase/Lowercase intrinsics, infer-based parsers (Split, Join, CamelCase), route-param extraction, JSON path keys, and typed i18n helpers.

05-25-2026#typescript#types#advanced

Structural Typing

Understand TypeScript's structural type system — assignability is based on shape, not name; excess property checks are the one exception; nominal typing requires branded types or class privates.

05-25-2026#typescript#types#concepts

satisfies Operator

TypeScript's satisfies operator checks a value against a type while preserving its narrow literal inferred type. The middle ground between an annotation that widens and an as cast that lies.

05-25-2026#typescript#types#operators

React with TypeScript

Type-safe React patterns — function components, prop types, children, event handlers, refs, generic components, polymorphic `as` props, and Zod-powered forms.

05-25-2026#typescript#react#ui

infer Keyword

TypeScript's infer keyword declares a fresh type variable inside a conditional type, letting you pull a sub-type out of a matched shape. It powers ReturnType, Parameters, Awaited, and most advanced type extractors.

05-25-2026#typescript#types#advanced

Discriminated Unions

Discriminated unions model finite states with a shared literal tag, enabling exhaustive narrowing in switch statements, Result-style error handling, reducer actions, and pattern-matched API responses.

05-25-2026#typescript#types#patterns

Declaration Merging

Deep dive into TypeScript declaration merging — interface merging, namespace + class, namespace + function, module augmentation, global augmentation, and the Express Request pattern.

05-25-2026#typescript#declarations#modules

Branded Types

Branded (a.k.a. nominal, opaque, tagged) types add a phantom marker to a primitive so the compiler refuses to mix two strings — useful for IDs, units, validated input, and money. Covers hand-rolled brands, type-fest's Opaque/Tagged, Zod's .brand(), class-based brands, and runtime validation pairings.

05-25-2026#typescript#types#patterns

.d.ts Files

Authoring .d.ts files — ambient declarations, declare module 'foo', asset typing (*.svg?raw), declare global, triple-slash refs, and the home-hero.svg?raw pattern used in this project.

05-25-2026#typescript#declarations#modules

Utility Types

TypeScript's built-in generic utility types that transform existing types into new ones. Covers Partial, Required, Readonly, Record, Pick, Omit, Exclude, Extract, ReturnType, Awaited, and more.

04-26-2026#typescript#utility-types#language

TypeScript Installation & Running

Install the TypeScript compiler, run .ts files without a build step using ts-node or tsx, and compile projects with tsc. Covers tsc flags, watch mode, and project references.

04-26-2026#typescript#installation#tsc

TypeScript

Static typing for JavaScript — tsconfig reference, the full type system, generics, utility types, narrowing, and common compiler errors explained.

04-26-2026#typescript#javascript#types

Types vs Interfaces

TypeScript has two ways to define object shapes — type aliases and interface declarations. Learn when each is appropriate, how they differ in extension, merging, and composability.

04-26-2026#typescript#types#interfaces

Type-Only Imports & Exports

import type and export type erase at compile time, preventing runtime side-effects and enabling better tree-shaking. Covers inline type qualifiers, verbatimModuleSyntax, and common gotchas with enums and namespaces.

04-26-2026#typescript#imports#modules

Type Narrowing

TypeScript narrowing refines broad types to specific ones within code branches. Covers typeof, instanceof, in, equality, assignment narrowing, discriminated unions, control flow analysis, and the never type.

04-26-2026#typescript#narrowing#type-guards

Type Guards

User-defined type guards narrow types at runtime using the `is` predicate, assertion functions, generic guards, and class-based patterns. Covers API validation, DOM guards, and when to use Zod.

04-26-2026#typescript#type-guards#narrowing

tsconfig.json Reference

Complete reference for tsconfig.json — compiler options for type checking, module resolution, output, paths, and JSX. Includes ready-to-use presets for Node 20, browser libraries, and Vite/React apps.

04-26-2026#typescript#tsconfig#compiler

Mapped & Conditional Types

Mapped types iterate over type keys to create new types; conditional types pick between types based on a condition. Together they power all built-in utility types and advanced type composition.

04-26-2026#typescript#mapped-types#conditional-types

Generics

TypeScript generics allow writing reusable, type-safe code that works over many types. Covers generic functions, interfaces, classes, constraints, keyof, conditional types, and the infer keyword.

04-26-2026#typescript#generics#language

Enums

TypeScript enums create named constant sets as real runtime objects. Covers numeric, string, and const enums; reverse mapping; enum pitfalls; and when to prefer a union of string literals instead.

04-26-2026#typescript#enums#language

Decorators

TypeScript decorators annotate and transform classes and class members. Covers the TC39 stage-3 standard decorators (TS 5.0+), legacy experimentalDecorators, decorator factories, method/class/field decorators, and reflect-metadata for NestJS and Angular patterns.

04-26-2026#typescript#decorators#language

Common TypeScript Errors

A reference for the most frequent TypeScript compiler errors — their meaning, a minimal reproduction, and the correct fix. Covers TS2304, TS2345, TS2339, TS2322, TS2532, TS2554, TS2307, TS2366, TS7006, TS2571, TS2769, TS2693, plus type assertions and ts-expect-error.

04-26-2026#typescript#errors#debugging