Type Alias for Objects in TypeScript
📖 Scenario: You are building a simple contact list app. Each contact has a name and an email.To keep your code clean and easy to understand, you want to create a type alias for the contact object.
🎯 Goal: Create a type alias called Contact for an object with name and email properties, then create a variable using this type and print the contact's details.
📋 What You'll Learn
Create a type alias called
Contact with name and email as string propertiesCreate a variable called
myContact of type Contact with name 'Alice' and email 'alice@example.com'Print the contact's name and email using
console.log💡 Why This Matters
🌍 Real World
Type aliases help keep code organized and clear when working with objects like user profiles, settings, or data records.
💼 Career
Understanding type aliases is important for writing clean, maintainable TypeScript code in many software development jobs.
Progress0 / 4 steps