Recall & Review
beginner
What is the syntax to import the default export from a module in TypeScript?Use <code>import name from 'module'</code> where <code>name</code> is the local name you want to assign to the default export.Click to reveal answer
beginner
How do you import named exports from a module?Use <code>import { export1, export2 } from 'module'</code> to import specific named exports.Click to reveal answer
intermediate
Explain how to import all exports from a module as a single object.Use <code>import * as alias from 'module'</code>. This imports everything and groups it under the name <code>alias</code>.Click to reveal answer
intermediate
What is the syntax to rename a named import during import?Use <code>import { originalName as aliasName } from 'module'</code> to rename a named export locally.Click to reveal answer
intermediate
How can you import a module for its side effects only?Use <code>import 'module'</code> without any bindings. This runs the module code but does not import any values.Click to reveal answer
Which syntax imports the default export from a module named 'utils'?
✗ Incorrect
The default export is imported using
import name from 'module' syntax.How do you import only the named export 'calculate' from a module 'math'?
✗ Incorrect
Named exports are imported using curly braces:
import { calculate } from 'math'.What does
import * as utils from 'utils' do?✗ Incorrect
This syntax imports all exports as properties of the object named 'utils'.
How do you rename a named import 'foo' to 'bar'?
✗ Incorrect
Use
{ originalName as alias } to rename imports.Which import syntax runs a module only for its side effects?
✗ Incorrect
Importing a module without bindings runs it for side effects only.
Describe the different ways to import modules in TypeScript and when to use each.
Think about how you get one export, many exports, or just run the module.
You got /5 concepts.
Explain how to rename a named export during import and why it might be useful.
Use the 'as' keyword in import statements.
You got /3 concepts.