A type constraint limits a generic argument to types that satisfy a required property, interface, class, or object-key relationship. TypeScript uses extends to enforce these requirements while preserving the specific type. section 3.8
Type-safe property access
function getProperty<T, K extends keyof T>(obj: T, key: K): T[K] { return obj[key]; } Calling getProperty({ a: 1, b: 2 }, "a") succeeds, while "c" produces a compile-time error.






