0
0
Typescriptprogramming~5 mins

Re-exporting modules in Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does re-exporting modules mean in TypeScript?
Re-exporting modules means exporting something from one module again through another module, so you can gather exports in one place for easier imports.
Click to reveal answer
beginner
How do you re-export all exports from another module?
Use export * from './module'; to re-export everything that the other module exports.
Click to reveal answer
beginner
How can you re-export a specific export from another module?
Use export { name } from './module'; to re-export only the named export.
Click to reveal answer
intermediate
Why use re-exporting in a project?
It helps organize code by creating a single entry point to import many things, making imports cleaner and easier to manage.
Click to reveal answer
intermediate
Can you rename exports while re-exporting? How?
Yes, you can rename exports using export { originalName as newName } from './module';.
Click to reveal answer
Which syntax re-exports all exports from a module named 'utils'?
Aexport * from './utils';
Bimport * from './utils';
Cexport { * } from './utils';
Dimport { * } from './utils';
How do you re-export only the 'calculate' function from 'math.ts'?
Aexport * from './math';
Bimport { calculate } from './math';
Cexport { calculate } from './math';
Dexport calculate from './math';
What is the benefit of re-exporting modules?
ATo rename files automatically
BTo make code run faster
CTo avoid using imports
DTo create a single place to import many exports
Can you rename an export while re-exporting it?
AYes, using 'as' keyword
BNo, renaming is not allowed
COnly if you import first
DOnly for default exports
Which statement is true about re-exporting?
AIt only works with default exports
BIt allows combining exports from multiple modules into one
CIt disables tree shaking
DIt duplicates code in the output
Explain how re-exporting modules works and why it is useful in TypeScript projects.
Think about how you can collect exports from many files into one place.
You got /4 concepts.
    Describe the difference between re-exporting all exports and re-exporting specific exports from a module.
    Consider when you want everything vs. only some parts.
    You got /4 concepts.