thecodex.expert · The Codex Family of Knowledge
Track 3 — Advanced

TypeScript: Advanced

Five lessons to master TypeScript — conditional types, mapped types, variance, and module augmentation.

🕐 ~5 hours5 lessonsTypeScript 5.x

Lessons

Lesson 1
Lesson 2

Mapped types and template literal types

[K in keyof T], re-mapping keys with as, adding/removing modifiers with + and -, template literal string types.

Prerequisite: Lesson 1 of Advanced

What to look for:

  • Mapped type = transform every property
  • + and - to add/remove readonly and optional
  • Key remapping with as: rename property keys
  • Template literal: `on${Capitalize}`
🕑 60 min
Lesson 3

satisfies, as const, and const type parameters

The satisfies operator, as const for literal inference, and const type parameters (TS 5.0).

Prerequisite: Lesson 2 of Advanced

What to look for:

  • satisfies: validate shape without widening
  • as const: string becomes "north" not string
  • Direction const object as enum alternative
  • const T in function: precise literal inference
🕑 45 min
Lesson 4

Module augmentation and global types

declare module, declare global, ambient declarations, and adding properties to third-party library types.

Prerequisite: Lesson 3 of Advanced

What to look for:

  • The Express Request augmentation pattern — you will use this in every Node app
  • declare global for adding to Window or globalThis
  • Ambient declarations: declare const: never overrides actual values
  • When to use .d.ts files vs inline declarations
🕑 30 min
Lesson 5

Variance and the limits of the type system

Covariance, contravariance, bivariance, intentional unsoundness, and known holes in TypeScript's type system.

Prerequisite: Lessons 1-4 of Advanced

What to look for:

  • The Deep Dive tab — TypeScript soundness and unsoundness
  • Covariant: readable positions (output)
  • Contravariant: writable positions (input)
  • as T assertions are a hole in the type system — use them sparingly
🕑 45 min

How to use this track: Each lesson links to the Codex reference page. Use reading level tabs. Check "What to look for". Come back here for the quiz.

Track quiz

4 questions on the Advanced track.

What does infer do in a conditional type?

What does [K in keyof T]: T[K] do?

What is the difference between satisfies and as?

Why is TypeScript intentionally unsound?

#128311; TypeScript Snippets

14 copy-ready TypeScript patterns with live Try it buttons.

TS Snippets #8594;