Advanced Types
Mapped Types — Partial, Required, Readonly, Record
Master Mapped Types ([K in keyof T]) in TypeScript, key remapping via 'as', modifier flags (+/-), and building Partial, Required, Readonly, and Record.
Last Updated: July 29, 2026
•
10 min read
Mapped Types allow you to create new object types by transforming existing object property keys and values. They build upon index signature syntax combined with the in operator and keyof.
1. Mapped Type Syntax
2. Building Core Utility Types
1. Partial (Make all properties optional)
2. Required (Make all properties required)
3. Readonly (Make all properties readonly)
4. Record (Create dictionary map)
3. Key Remapping via as Clause (TypeScript 4.1+)
You can filter or rename property keys in a mapped type using the as clause and Template Literal types:
4. Interactive Code Playground
Test mapped types below:
5. Summary Table
| Modifier | Syntax | Effect |
|---|---|---|
| Add Optional | [K in keyof T]?: T[K] | Makes properties optional |
| Remove Optional | [K in keyof T]-?: T[K] | Makes optional properties required |
| Add Readonly | readonly [K in keyof T]: T[K] | Makes properties read-only |
| Remove Readonly | -readonly [K in keyof T]: T[K] | Makes read-only properties mutable |
[K in keyof T as NewKey]: T[K] | Renames or filters keys |