typeof

  1. const userAccount = {
  2. name: "Kieron",
  3. id: 0,
  4. };
  5. // You can combine these to make larger, more complex
  6. // data-models.
  7. const pie = {
  8. type: "Apple",
  9. };
  10. const purchaseOrder = {
  11. owner: userAccount,
  12. item: pie,
  13. };
  14. type PurchaseOrder = typeof purchaseOrder;
  15. // Creates a readonly array of purchase orders
  16. const readonlyOrders: readonly PurchaseOrder[] = [purchaseOrder];
  17. // error
  18. readonlyOrders.pop();