A mapped type iterates over a union of keys (often `keyof T`) and produces a new property for each, optionally changing its modifiers or type.
ts
type Flags<T> = {
[K in keyof T]: boolean;
};
interface Token { symbol: string; decimals: number; }
type TokenFlags = Flags<Token>; // { symbol: boolean; decimals: boolean }
type ReadonlyVersion<T> = {
readonly [K in keyof T]: T[K];
};
type OptionalVersion<T> = {
[K in keyof T]?: T[K];
};This is exactly how built-ins like `Partial<T>` and `Readonly<T>` are implemented internally. You can also add `as` clauses to rename keys (key remapping), e.g. `[K in keyof T as `get${string & K}`]: () => T[K]` to generate getter method names.