What are Mapped Types and how can you use them to transform an object?
Updated May 4, 2026
Short answer
Mapped types allow you to create new types based on the properties of an existing type by iterating over keys.
Deep explanation
Mapped types use the keyof operator to iterate through keys of an existing type and apply a transformation. This is essential for creating variations of a type without duplicating code. You can add or remove modifiers like readonly or ? using the + or - prefix. Since TypeScript 4.1, you can also use 'Key Remapping' with the as clause to change the property names themselves during the mapping process.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro