Mapped Types
A mapped type builds a new type by looping over keys.
Example
type Flags<T> = { [K in keyof T]: boolean };
type F = Flags<{ a: number; b: string }>;
const f: F = { a: true, b: false };
console.log(f);Result
{
a: true,
b: false,
}Exercise
Loop over keys.
[K keyof T]
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.