advanced9 h 20 min16 lessons

Advanced TypeScript

The type system as a programmable language. Conditional and mapped types, template literals, inference, variance, declaration files, library authoring, branded types, the compiler API, type-checking performance, and knowing when a clever type has become a liability.

by DevFox

Start course

What you will cover

  1. Conditional TypesTypes that branch on other types: the extends check, distribution over unions and how to stop it, and the recursion that makes them genuinely powerful.35 min
  2. Mapped Types and Key RemappingTransforming every property of a type at once: modifiers, adding and removing optionality, and remapping keys with as to build derived shapes.35 min
  3. Template Literal TypesTypes built from string patterns: parsing and constructing strings at the type level, and the APIs this makes safe that were previously just documented.35 min
  4. Inference Deep DiveHow the compiler decides a type: infer, contextual typing, inference sites and priority, widening and literal types, and diagnosing why inference produced something too wide.35 min
  5. Variance, Assignability, and Structural TypingWhat makes one type assignable to another, co- and contravariance in function types, method bivariance and the unsoundness it permits.35 min
  6. Function Overloads and Call SignaturesDescribing a function with several legitimate shapes, ordering overloads so the right one wins, and when a union or generic beats overloading entirely.35 min
  7. Type-Level Programming and Its LimitsRecursion depth, instantiation limits and compile-time cost. What can be computed in types, what should be, and the error message a colleague will have to read.35 min
  8. Declaration Files and Ambient TypesWriting .d.ts by hand, declaring modules and globals, augmenting types you do not own, and keeping ambient declarations from leaking everywhere.35 min
  9. Authoring a Typed LibraryDesigning a public type surface, exports maps, shipping declarations for multiple module formats, and treating a type change as a breaking change when it is one.35 min
  10. Generics That ScaleTyping higher-order functions, preserving parameter types through wrappers, fluent builders that stay inferable, and generics that read well at the call site rather than the definition.35 min
  11. Branded and Nominal TypesMaking two structurally identical types incompatible on purpose — validated input, identifiers, units — and the ergonomics of constructing and unwrapping them.35 min
  12. The Compiler API and Custom ToolingReading your codebase as an AST: writing a codemod, a custom lint rule or a generator, and the maintenance cost of tooling that knows about your syntax.35 min
  13. Type Checking PerformanceWhy an editor becomes slow: measuring with compiler diagnostics, finding the type that costs seconds, and the rewrites that give the time back.35 min
  14. Decorators and MetadataThe standardised decorator model, what each decorator kind can do, metadata, and the narrow cases where a decorator beats a plain function call.35 min
  15. Assertion Functions and satisfiesasserts signatures that narrow for the rest of a scope, satisfies for checking without widening, and const type parameters that preserve literals.35 min
  16. Interop with Untyped CodeMigrating incrementally, containing any at a boundary, typing a legacy module from the outside, and measuring progress so a migration actually finishes.35 min