0Pricing
TypeScript Academy · Lesson

Mapped types with +/-readonly and +/-?

Explore mapped types and modifiers (+/-readonly, +/-optional) to create flexible variations of object shapes.

Intro

Goal: Learn mapped types with modifiers to alter object properties systematically. They let you create readonly, optional, or required versions of types.

Basic mapped type

A mapped type iterates keys and reuses property types. This is the foundation for transformations.

type Options = { a: string; b: number }

type Clone<T> = { [K in keyof T]: T[K] }

type Copy = Clone<Options>  // { a: string; b: number }

All lessons in this course

  1. Mapped types with +/-readonly and +/-?
  2. Key remapping & template literal types
  3. String-pattern typing (route params, event names)
← Back to TypeScript Academy