0
0
Typescriptprogramming~20 mins

Export syntax variations in Typescript - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Export Syntax Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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);
A"greeting"
Bundefined
C"Hello"
DReferenceError
Attempts:
2 left
💡 Hint
Think about how named exports and imports work in TypeScript.
Predict Output
intermediate
2: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);
Aundefined
B"Welcome"
CSyntaxError
D"message"
Attempts:
2 left
💡 Hint
Default exports can be imported with any name.
Predict Output
advanced
2: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);
AReferenceError
Bundefined
CSyntaxError
D42
Attempts:
2 left
💡 Hint
Re-exporting with alias changes the exported name.
Predict Output
advanced
2:00remaining
What error occurs with incorrect export syntax?
What error will this TypeScript code produce?
Typescript
export const x = 10;
export default x;
ASyntaxError: Unexpected token 'export'
BNo error, runs fine
CSyntaxError: Missing semicolon
DTypeError: Duplicate export default
Attempts:
2 left
💡 Hint
Check if multiple export statements need semicolons or line breaks.
🧠 Conceptual
expert
2: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.
Aexport { a as alpha, b as beta };
Bexport const alpha = a, beta = b;
Cexport default { alpha: a, beta: b };
Dexport * from { a as alpha, b as beta };
Attempts:
2 left
💡 Hint
Look for the syntax that uses aliasing in export braces.