Complete worked example
typescript
function get<T, K extends keyof T>(object: T, key: K): T[K] { return object[key]; }
const role = { title: "QA", count: 2 };
const count: number = get(role, "count");- Reasoning
- K connects the literal key argument to its selected value type T[K].