TypeScript tip: When migrating a web app to TypeScript, strongly type HTTP...


TypeScript tip: When migrating a web app to TypeScript, strongly type HTTP responses first.

HTTP responses tend to be passed throughout the app. So, strongly typing each HTTP response strongly types most of the app! 👍

#typescript
3 ways to generate TypeScript types for API responses:

1. In GraphQL? Use GraphQL Codegen.

2. In REST? Generate types via an OpenAPI spec.

3. Use Zod to declare the expected response in detail and generate types from that.

View original on X