A frontend application can compile successfully and still fail when it communicates with the backend.
Imagine a backend developer changes an API response from:
{ "id" : 42 , "name" : "Alex" , "email" : "[email protected]" }
to:
{ "id" : 42 , "fullName" : "Alex" , "email" : "[email protected]" }
The backend works correctly. The frontend also builds without errors. However, a component expecting user.name now receives undefined .
This is an example of API contract drift: the frontend and backend no longer agree on the structure or behavior of an API.
The problem becomes more difficult when several developers or teams work on different parts of an application. A change made by one team may affect another team's assumptions without producing an obvious error during development.
TypeScript helps catch many programming mistakes, but its types do not automatically validate data received over HTTP.…