Session: Type-Safe APIs – Syncing Back & Front End Types w/ Code Generation

The same thing that makes SPAs great for large apps (separation of concerns & resources) also makes them really frustrating in one particular way: consistency between models & definitions, between back & front end code. The answer: code generation tools, to take API definitions & output usable TypeScript. We’ll discuss how we can go from the most frustrating part of any SPA development workflow, to what can become the most satisfying. We’ll focus primarily on Open API & Swagger, 2 potential API definition standards, while referencing tools for other cases (even a bit of GraphQL). We’ll talk about making use of generated interfaces to reduce code duplication & increase type safety across our apps. We’ll look at code organization patterns in front-end frameworks, to minimize the hassle of referencing generated TypeScript files in the first place. And we’ll talk briefly about CI & NPM versioning patterns we use @ POLITICO to automate this process in quite useful ways.

Presenters: