Challenge - 5 Problems
Export Syntax Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of named export usage?
Consider the following TypeScript module and usage. What will be logged to the console?
Typescript
export const greeting = 'Hello'; // In another file import { greeting } from './module'; console.log(greeting);
Attempts:
2 left
💡 Hint
Think about how named exports and imports work in TypeScript.
✗ Incorrect
The named export 'greeting' is imported correctly and logs the string 'Hello'.
❓ Predict Output
intermediate2:00remaining
What does default export import log?
Given this module and import, what will be the console output?
Typescript
const message = 'Welcome'; export default message; // In another file import msg from './module'; console.log(msg);
Attempts:
2 left
💡 Hint
Default exports can be imported with any name.
✗ Incorrect
The default export is the string 'Welcome'. Importing it as 'msg' logs 'Welcome'.
❓ Predict Output
advanced2:00remaining
What is the output when re-exporting with alias?
Analyze this code snippet. What will be the output of the console.log statement?
Typescript
export const value = 42; export { value as answer }; // In another file import { answer } from './module'; console.log(answer);
Attempts:
2 left
💡 Hint
Re-exporting with alias changes the exported name.
✗ Incorrect
The constant 'value' is exported as 'answer'. Importing 'answer' logs 42.
❓ Predict Output
advanced2:00remaining
What error occurs with incorrect export syntax?
What error will this TypeScript code produce?
Typescript
export const x = 10; export default x;
Attempts:
2 left
💡 Hint
Check if multiple export statements need semicolons or line breaks.
✗ Incorrect
Missing semicolon causes the parser to misinterpret the second export, causing SyntaxError.
🧠 Conceptual
expert2:00remaining
Which export syntax allows exporting multiple items with different names in one statement?
Choose the correct export syntax that exports two variables 'a' and 'b' with aliases 'alpha' and 'beta' respectively in a single export statement.
Attempts:
2 left
💡 Hint
Look for the syntax that uses aliasing in export braces.
✗ Incorrect
Option A correctly exports 'a' and 'b' with aliases 'alpha' and 'beta' in one statement.