Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumTypeScriptgeneric constraintsSingle-choice MCQ

Why does TypeScript reject indexing `obj[key]` inside this generic, even though both type parameters look related?

function get<T, K extends string>(obj: T, key: K) { return obj[key]; }