Recall & Review
beginner
What is a module in TypeScript?
A module is a file that contains code (variables, functions, classes) and can export or import them to share with other files.Click to reveal answer
beginner
How do you declare a module in TypeScript?
You declare a module by creating a file and using
export to share parts of the code, and import to use code from other modules.Click to reveal answer
intermediate
What is the difference between a global script and a module in TypeScript?
A global script shares variables globally without imports/exports. A module has its own scope and shares code only through exports and imports.
Click to reveal answer
intermediate
What does the
declare module syntax do in TypeScript?It tells TypeScript about the shape of a module that exists elsewhere, often used to describe modules without TypeScript code (like JavaScript libraries).
Click to reveal answer
beginner
How do you export a function named
greet from a module?Use <code>export function greet() { ... }</code> to make the function available to other modules.Click to reveal answer
Which keyword is used to share code from a TypeScript module?
✗ Incorrect
The
export keyword is used to share code from a module.How do you use code from another module in TypeScript?
✗ Incorrect
The
import keyword is used to bring code from another module.What does
declare module 'xyz' do?✗ Incorrect
It declares the type information for an external module.
Which of these is true about modules in TypeScript?
✗ Incorrect
Modules have their own scope and share code only via exports.
What file extension is typically used for a TypeScript module?
✗ Incorrect
TypeScript modules usually use the
.ts extension.Explain how to declare and use a module in TypeScript.
Think about how you share and use code between files.
You got /4 concepts.
Describe the purpose of the
declare module statement in TypeScript.It helps TypeScript know about modules without code.
You got /4 concepts.