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.

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

Lessons