TYPESCRIPTChapter 4 · TS Expert
Mapped Types
Mapped Types build new types by iterating over the keys of an existing type. They map every property of a type to a new type structure, similar to Array.prototype.map() but for type properties.
Worked example
How it reads
- [K in keyof T] iterates over all keys K inside type T
- T[K] accesses the type of property K in type T

Cloud tip: Mapped types are useful for converting API responses or validation payloads dynamically.


