Mapped Type
Question
What is a mapped type?
Hint
Mapped types use [P in keyof T] syntax.
Explanation
A mapped type transforms each property of an existing type using a keyed mapped type. Syntax: { [P in keyof T]: NewType }. Example: type Stringify<T> = { [P in keyof T]: string } converts all properties to string. Modifiers: + or - to add/remove readonly/optional. type Mutable<T> = { -readonly [P in keyof T]: T[P] } removes readonly. The built-in utility types (Partial, Required, Readonly, Pick) are all mapped types. Mapped types are powerful for creating type transformations generically.
Related Resources
Related Lessons
- Mapped Types
Learn mapped types.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.