Grokking TypeScript
Vote

0% completed

​

Mapped Types

You can build a new object type by visiting each property of an existing type and deciding what to do with it. This feature is called a mapped type, and it works much like the map method on an array, except that it visits the keys of a type at compile time.

Mapped types solve a common problem. Suppose an application has a User interface, and it also needs a version where every property is optional and another where every property is read-only.

interface User { id: number; name: string; age: number; email: string; }

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content