Recall & Review
beginner
What is a type alias in TypeScript?
A type alias is a custom name you give to a type or a combination of types. It helps you reuse and simplify complex types by giving them a simple name.
Click to reveal answer
beginner
What does inline type mean in TypeScript?
An inline type is a type written directly where it is used, without giving it a separate name. It is often used for quick, one-time type definitions.
Click to reveal answer
beginner
Give an example of a type alias for an object with properties
name (string) and age (number).type Person = { name: string; age: number; };
Click to reveal answer
beginner
How would you write the same object type
{ name: string; age: number; } as an inline type in a function parameter?function greet(person: { name: string; age: number }) { /* ... */ }Click to reveal answer
intermediate
What is one advantage of using type aliases over inline types?
Type aliases make code easier to read and reuse because you give complex types a simple name and can use them multiple times without repeating the full type.
Click to reveal answer
Which of the following is a correct type alias declaration in TypeScript?
✗ Incorrect
The correct keyword for creating a type alias in TypeScript is 'type'.
What is an inline type in TypeScript?
✗ Incorrect
Inline types are written directly where needed without giving them a separate name.
Why might you prefer a type alias over inline types?
✗ Incorrect
Type aliases help reuse types and make code easier to read.
Which of these is an example of an inline type used in a function parameter?
✗ Incorrect
The type is written directly inside the function parameter without a name, so it's inline.
Which keyword is used to create a type alias in TypeScript?
✗ Incorrect
The 'type' keyword is used to create type aliases in TypeScript.
Explain the difference between a type alias and an inline type in TypeScript.
Think about naming and reuse.
You got /4 concepts.
When would you choose to use a type alias instead of an inline type?
Consider code reuse and clarity.
You got /4 concepts.