Basic mapped type syntax
📖 Scenario: You are working on a TypeScript project where you want to create a new type that changes all properties of an existing type to be optional.
🎯 Goal: Learn how to use basic mapped type syntax in TypeScript to create a new type with all properties optional.
📋 What You'll Learn
Create an interface called
Person with exact propertiesCreate a mapped type called
OptionalPerson that makes all Person properties optionalUse the mapped type syntax with
keyof and inPrint the type of
OptionalPerson to verify💡 Why This Matters
🌍 Real World
Mapped types help you transform existing types easily, useful in large projects to create flexible data shapes.
💼 Career
Understanding mapped types is important for TypeScript developers to write clean, reusable, and type-safe code.
Progress0 / 4 steps