Recall & Review
beginner
What is a module in TypeScript?
A module is a file that contains code (like variables, functions, or classes) which can be shared and used in other files.
Click to reveal answer
beginner
Why do we need modules in TypeScript?
Modules help organize code by splitting it into smaller, manageable parts and avoid name conflicts by keeping code private unless exported.
Click to reveal answer
intermediate
How do modules help avoid name conflicts?
Each module has its own scope, so variables or functions inside one module don’t clash with those in another unless explicitly shared.
Click to reveal answer
beginner
What keywords are used to share code between modules?
The
export keyword is used to share code, and import is used to bring that code into another module.Click to reveal answer
intermediate
How do modules improve code maintainability?
By breaking code into modules, it becomes easier to update, test, and reuse parts without affecting the whole program.
Click to reveal answer
What is the main purpose of modules in TypeScript?
✗ Incorrect
Modules help organize code and prevent name conflicts by keeping code scoped.
Which keyword is used to share code from a module?
✗ Incorrect
The
export keyword shares code from a module.How do modules help with code scope?
✗ Incorrect
Modules keep code private unless explicitly exported, avoiding conflicts.
What keyword do you use to bring code from another module?
✗ Incorrect
The
import keyword brings code from another module.Which benefit is NOT provided by using modules?
✗ Incorrect
Modules help organize and maintain code but do not automatically fix errors.
Explain why modules are important in TypeScript and how they help manage code.
Think about how splitting a big task into smaller tasks makes it easier to handle.
You got /4 concepts.
Describe how the export and import keywords work in TypeScript modules.
Imagine sharing toys with friends and asking to borrow theirs.
You got /3 concepts.