0
0
Typescriptprogramming~5 mins

Export syntax variations in Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the syntax to export a single variable in TypeScript?
Use <code>export const variableName = value;</code> to export a single variable.
Click to reveal answer
beginner
How do you export multiple variables or functions at once?
Use export { name1, name2, name3 }; to export multiple items together.
Click to reveal answer
intermediate
What is the difference between default export and named export?
Default export exports a single value per file using export default. Named exports export multiple values by name using export.
Click to reveal answer
intermediate
How do you rename an export while exporting it?
Use export { originalName as newName }; to rename an export.
Click to reveal answer
intermediate
How do you re-export everything from another module?
Use export * from './module'; to re-export all exports from another file.
Click to reveal answer
Which syntax exports a default function in TypeScript?
Aexport myFunc() default {}
Bexport function default myFunc() {}
Cexport default function myFunc() {}
Ddefault export function myFunc() {}
How do you export multiple variables named a and b together?
Aexport a & b;
Bexport { a, b };
Cexport (a, b);
Dexport a, b;
What does export * from './file'; do?
AExports nothing
BImports all exports from './file' only
CDeletes all exports from './file'
DExports all exports from './file' again from current file
How to rename export 'foo' to 'bar' while exporting?
Aexport { foo as bar };
Bexport { bar as foo };
Cexport foo to bar;
Dexport rename foo to bar;
Which is NOT a valid export syntax?
Aexport function() {}
Bexport default class MyClass {}
Cexport const x = 5;
Dexport { x, y };
Explain the difference between named exports and default exports in TypeScript.
Think about how you import them too.
You got /3 concepts.
    Describe how to re-export all exports from another module and why it might be useful.
    Imagine combining exports from many files into one.
    You got /3 concepts.