-
Notifications
You must be signed in to change notification settings - Fork 0
keyof and typeof
Jorge Castro edited this page Nov 10, 2025
·
1 revision
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;const product = {
id: 1,
name: "Sample Product",
price: 19.99,
description: "This is a sample product description.",
};
type Product = typeof product;- Sync-Obsidian-with-GitHub-on-iOS
- Obsidian-community-plugins
- Optimizing-Novel-Word-Count-Plugin-for-Git-Users
- What is TypeScript, and why you should use it
- Quick setup
- Inference and type annotations
- Fundamental Types
- Object Types
- Union Types
- Type Aliases and Interfaces
- Type Assertions
- Literal Types
- null and undefined
- Narrowing
- Creating Types from Types
- Common Built‐in and Utility Types
- tsc CLI ‐ (The Compiler)
- Avoid using Object or {}
- Ignoring TypeScript errors
- TypeScript resources