keyof and typeof

keyof

const linksStructure = {
  home: { title: "Home", url: "/"  },
  about: { title: "About Us", url: "/about" },
  services: { title: "Services", url: "/services" },
  contact: { title: "Contact", url: "/contact" },
}

const getUrl = (key: keyof typeof linksStructure) => linksStructure[key].url;

typeof

const product = {
  id: 1,
  name: "Sample Product",
  price: 19.99,
  description: "This is a sample product description.",
};
type Product = typeof product;