Code QuizIntermediate

Constraint Referencing Another Parameter

Detecting a reversed constraint between two type parameters.

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

const user = { id: 1, name: "Ada" };
getProp(user, "name");

What is the bug in this code?