Packages and typed APIs

This part puts a package into the program: an npm package installed and imported by name, a bundler with one entry and a measured output, the route state of a single page app, a typed API client over fetch, and the validation of unknown JSON with small type guards.

11.1 Npm packages install a shared TypeScript package, import it by name, and pin the version Open 11.2 Bundling concept many modules into few browser files, one entry, and a measured output size Open 11.3 SPA concepts a route state, a render function and JSON loading in one small single page app Open 11.4 Typed API client fetch wrapped in a typed GET and POST that throw a shaped error Open 11.5 Hand-rolled validation type guards that parse unknown JSON, collect every error, and compose Open

Lessons