Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

Text · 10 lines · 309 B · at 9c48a39

// Mutating an argument changes data the caller still holds.type Cart = { items: string[]; total: number };const addItem = (cart: Cart, item: string, price: number): Cart => {  cart.items.push(item);  cart.total += price;  return cart;};console.log(addItem({ items: [], total: 0 }, "tea", 3).total);