Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Your server should export the types. Don't write types by hand in your client, that makes no sense. The server knows what data it is sending and should provide that information as metadata to the client. Practically this can mean that a Python backend uses Pydantic schemas which can be used to automatically generate an OpenAPI specification that your client can use to generate types.


This answer is how I wish the world would work, but I am stuck with a server with a poor type system that can't refine the types nearly as accurately as TS can. :(




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: