Real World Example

Typed Order Confirmation

Food delivery apps like Swiggy and Zomato use TypeScript on their web front ends and Node.js services. A typed order object guarantees every screen and email gets the fields it needs.

Example

type Order = {
  id: string;
  restaurant: string;
  items: number;
  amount: number;
};

function confirmation(order: Order): string {
  return "Order " + order.id + " from " + order.restaurant +
    ": " + order.items + " items, Rs. " + order.amount.toFixed(2);
}

const order: Order = { id: "SW-1042", restaurant: "Paradise Biryani", items: 2, amount: 549 };
console.log(confirmation(order));
console.log("Estimated delivery in 35 minutes.");

Output

Order SW-1042 from Paradise Biryani: 2 items, Rs. 549.00
Estimated delivery in 35 minutes.

What Changes When the API Changes

If the backend team renames amount to total and you update the Order type, TypeScript immediately lists every function that still uses amount. In a JavaScript codebase you would find out from customer complaints.