Create a type by iterating over keys.
Section: Mapped and Conditional Types
Simple mapped type
typescript
typescript
type Flags<T> = {
[K in keyof T]: boolean;
};Explanation
Mapped types let you derive new object types from existing ones.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Mapped and Conditional Types
Discriminated union pattern
Model variant objects with a shared discriminant field.
Generic identity function
Use a type parameter for reusable function typing.