Home / Companies / Speakeasy / Blog / Post Details
Content Deep Dive

TypeScript forward compatibility and fault tolerance

Blog post from Speakeasy

Post Details
Company
Date Published
Author
David Adler
Word Count
1,310
Language
English
Hacker News Points
-
Summary

SDKs, especially when integrated with evolving APIs, can present challenges such as receiving a 200 response from the server alongside an SDK error due to strict validation practices. This often occurs due to API changes like new enum values or missing fields, which can cause SDKs to reject responses despite successful server processing. To address these issues, Speakeasy SDKs offer client-side solutions that maintain functionality amidst API evolution without compromising type safety or developer experience. These include forward-compatible enums and unions, lax mode for handling missing fields, and smart union deserialization for better type discrimination. While server-side solutions like tagging API versions and contract testing can mitigate such issues, they might not be feasible for all API providers, making client-side adaptability crucial. The features of Speakeasy SDKs are tailored to TypeScript but similar behaviors are implemented across other languages, ensuring a robust developer experience as APIs grow and change.