Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. TypeScript Mastery

Lesson 11 of 56 · Typescript

Mapped Types & `keyof`

Duration: 20 minutes

keyof Operator

type Person = { name: string; age: number; };
type PersonKeys = keyof Person; // "name" | "age"

Mapped Types – Transform each property

type ReadonlyPerson = { readonly [K in keyof Person]: Person[K] };
// equivalent to: { readonly name: string; readonly age: number; }

Partial & Required

type PartialPerson = Partial<Person>; // all props optional
type RequiredPerson = Required<PartialPerson>; // back to required

Record Utility

type RoleMap = Record<string, "admin" | "user" | "guest">;
const roles: RoleMap = { alice: "admin", bob: "user" };

Info

Mapped types let you programmatically transform object shapes.

Previous: Generic ConstraintsNext: Conditional Types