Recall & Review
beginner
What is a type alias in TypeScript?
A type alias is a way to give a new name to a type. It helps make complex types easier to read and reuse.
Click to reveal answer
beginner
Why do we need type aliases instead of repeating types everywhere?
Type aliases reduce repetition and make code easier to maintain. If a type changes, you only update it in one place.
Click to reveal answer
beginner
How do type aliases improve code readability?
By giving meaningful names to complex types, type aliases make code easier to understand at a glance.
Click to reveal answer
intermediate
Can type aliases represent union types? Give an example.
Yes. For example, type Status = 'success' | 'error' | 'loading'; creates a type alias for these string values.
Click to reveal answer
intermediate
What is one difference between type aliases and interfaces in TypeScript?
Type aliases can represent primitive types, unions, and tuples, while interfaces mainly describe object shapes.
Click to reveal answer
What is the main benefit of using type aliases in TypeScript?
✗ Incorrect
Type aliases help by naming types, making code easier to read and reuse.
Which of these can a type alias NOT represent?
✗ Incorrect
Type aliases represent types, not actual HTML elements.
If you want to change a complex type used in many places, what helps you avoid changing it everywhere?
✗ Incorrect
Using a type alias means you only update the type in one place.
Which syntax correctly defines a type alias for a union of string literals?
✗ Incorrect
Type aliases use the 'type' keyword and can define unions like in option C.
Which statement is true about type aliases and interfaces?
✗ Incorrect
Type aliases can represent unions and primitives; interfaces mainly describe object shapes.
Explain why type aliases are useful in TypeScript and give an example.
Think about how naming a type helps when you use it many times.
You got /3 concepts.
Describe the difference between type aliases and interfaces in TypeScript.
Consider what kinds of types each can represent.
You got /3 concepts.