RecipesChapter 12: Type Development Strategies

Working Around Index Access Restrictions

Recipe 12.6 from The TypeScript Cookbook

function update<K extends keyof Person>(key: K) {
  person[key] = anotherPerson[key]; // works
}

update("age");
Open in TypeScript Playground →