Challenge - 5 Problems
Export Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of importing default export
What will be the output of this TypeScript code when run?
Typescript
export default function greet() { return "Hello from default export!"; } import greet from './module'; console.log(greet());
Attempts:
2 left
💡 Hint
Default exports can be imported with any name without braces.
✗ Incorrect
The function is exported as default and imported without braces, so calling greet() works and returns the string.
❓ Predict Output
intermediate2:00remaining
Output of importing named export
What will be the output of this TypeScript code when run?
Typescript
export function greet() { return "Hello from named export!"; } import { greet } from './module'; console.log(greet());
Attempts:
2 left
💡 Hint
Named exports must be imported with braces and exact names.
✗ Incorrect
The function is exported as a named export and imported with braces using the same name, so calling greet() returns the string.
❓ Predict Output
advanced2:00remaining
What happens if you import a named export as default?
Given this module code, what will be the output or error when running the import code?
Typescript
export function greet() { return "Hello!"; } import greet from './module'; console.log(greet());
Attempts:
2 left
💡 Hint
Default import expects a default export, but only named export exists.
✗ Incorrect
Since the module exports greet as a named export, importing it as default results in greet being undefined or an object, causing a TypeError when called.
🧠 Conceptual
advanced2:00remaining
Difference in importing multiple named exports vs default export
Which statement correctly describes the difference between importing multiple named exports and a default export in TypeScript?
Attempts:
2 left
💡 Hint
Think about how you write import statements for default vs named exports.
✗ Incorrect
Named exports require braces and exact names; default exports do not use braces and can be renamed on import.
❓ Predict Output
expert3:00remaining
Output of combined default and named exports import
What will be the output of this TypeScript code when run?
Typescript
export default function greet() { return "Hello from default!"; } export function greetNamed() { return "Hello from named!"; } import greet, { greetNamed } from './module'; console.log(greet()); console.log(greetNamed());
Attempts:
2 left
💡 Hint
You can import default and named exports together in one statement.
✗ Incorrect
The default export is imported as greet without braces; the named export greetNamed is imported with braces. Both functions return their respective strings.