Mapped Types: Transforming Object Types
Loop over keys to create new type shapes.
Welcome
Mapped types iterate over the keys of a type to create new types with transformed properties. They are the foundation of Partial, Readonly, Record, and many other utilities.
Basic Mapped Type Syntax
Use `[K in keyof T]` to iterate over all keys of T and produce a new type.
type Copy<T> = { [K in keyof T]: T[K] };
type UserCopy = Copy<User>; // same as UserAll lessons in this course
- Mapped Types: Transforming Object Types
- Modifiers in Mapped Types: readonly and ?
- Template Literal Types: String Patterns
- Key Remapping with as in Mapped Types