7 Replies
Good enought for who? It does not give you any typesafety
Thats what I thought yeah. What would be a good type for JSON values?
Values that you have on the data
Yeah but I mean mostly API responses. Should I really type every response and cast it to axios.get<Type> for example?
The more you type things now, the less pain you will feel later.
generic casting is better than nothing but there still no guarentee that what comes back is actually the type your telling typescript it is
use zod: https://zod.dev/ to validate your data and make sure it matches what you expect
GitHub
TypeScript-first schema validation with static type inference
TypeScript-first schema validation with static type inference
its as easy as defining a schema and parsing your data
what your get back will be fully typed as infered from your schema