1 min readJul 8, 2019
You should generate types from specs rather than responses. Using sample data to generate types implicitly assumes that the response was representative. But in practice it really is important to know which fields are nullable and which fields could have one of three possible shapes. If there’s a published schema for the API you’re working with, you should use that. quicktype can generate TypeScript from GraphQL or JSONSchema, for instance.