Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a type alias named Person for an object with a name string property.
Typescript
type Person = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets or parentheses instead of curly braces.
Forgetting the colon between property name and type.
✗ Incorrect
A type alias for an object uses curly braces with property names and their types inside, like
{ name: string }.2fill in blank
mediumComplete the code to define a type alias Car with make and year properties.
Typescript
type Car = { make: string; [1]: number }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong property name like
model or color.Using a string type instead of number for the year.
✗ Incorrect
The
Car type alias should have a year property of type number.3fill in blank
hardFix the error in the type alias by completing the code correctly.
Typescript
type Book = [1] title: string; author: string }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using square brackets or parentheses instead of curly braces.
Missing the opening brace causes syntax errors.
✗ Incorrect
Type aliases for objects must start with an opening curly brace
{.4fill in blank
hardFill both blanks to define a type alias Employee with id as a number and name as a string.
Typescript
type Employee = { [1]: number; [2]: string }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property names like
age or salary.Swapping the types of the properties.
✗ Incorrect
The
Employee type alias has id as number and name as string properties.5fill in blank
hardFill all three blanks to define a type alias Product with id (number), name (string), and inStock (boolean).
Typescript
type Product = { [1]: number; [2]: string; [3]: boolean }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong property names like
available instead of inStock.Mixing up the order of properties.
✗ Incorrect
The
Product type alias has id as number, name as string, and inStock as boolean properties.