TypeScript · Middle · Question 5 of 75
What is a mapped type?
type Flags<T> = { [K in keyof T]: boolean };- ✓Correct answer: A type that creates new properties by iterating over another type's keys
- 2A type for the
Mapobject from the JavaScript standard library - 3A type that maps object values at runtime
Explanation
[K in keyof T] iterates over the keys. You can change the value type, add or remove modifiers (readonly, ?, -?) and rename keys with as. Partial, Readonly and Record are built on mapped types.