Safely Handling Dynamic Data with TypeScript
summary
Combines TypeScript static types with runtime JSON Schema validation to make API inputs and responses safe, using Fastify + TypeBox + AJV on the server and the Indici HTTP client on the client. Builds a POST /add-user route that derives TypeScript types from TypeBox schemas, validates requests with AJV, and returns "user 123 was added successfully" in the demo; sending wrong fields yields a 400 and the client logs the unexpected response.
AI-written summary · about
chapters (6)
- 0:00Introduction to dynamic data
- 1:11The dangers of unknown types
- 3:09Leveraging JSON schema
- 7:27Client-side type safety
- 10:28Live coding demonstration
- 15:57Conclusion and resources
related talks
20mSafely Handling Dynamic Data with TypeScript
39mEnd to end typing for web applications
35mFull-stack Type Safety with React, GraphQL, and TypeScript
20mREST API Validation in a Typescript front-end
30mTypeScript: Gradual, Structural, Dynamic, Static
21mThe long-tail of type safety
26mFull Stack Type Safety with React, GraphQL, and TypeScript
39mJSONSchema as a runtime type system - Advanced concepts and practical uses
