Challenge - 5 Problems
TypeScript Compiler Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output after compiling and running this TypeScript code?
Consider this TypeScript code snippet. After compiling it with the TypeScript compiler and running the resulting JavaScript, what will be printed to the console?
Typescript
const greet = (name: string): string => { return `Hello, ${name}!`; }; console.log(greet("Alice"));
Attempts:
2 left
💡 Hint
Think about what the function returns and what console.log prints.
✗ Incorrect
The function greet returns the string 'Hello, Alice!'. When compiled and run, console.log prints this string to the console.
🧠 Conceptual
intermediate1:30remaining
Which command installs the TypeScript compiler globally?
You want to install the TypeScript compiler so you can use the 'tsc' command anywhere on your computer. Which command should you run?
Attempts:
2 left
💡 Hint
Global installation allows using the command in any folder.
✗ Incorrect
The '-g' flag installs the package globally, making the 'tsc' command available everywhere.
🔧 Debug
advanced2:00remaining
What error occurs when compiling this TypeScript code?
Look at this TypeScript code. When you run 'tsc' to compile it, what error will the compiler show?
Typescript
let count: number = "five"; console.log(count);
Attempts:
2 left
💡 Hint
Check the type assigned to 'count' and the declared type.
✗ Incorrect
The variable 'count' is declared as a number but assigned a string, causing a type error.
📝 Syntax
advanced1:30remaining
Which command compiles all TypeScript files in the current folder using a config file?
You have a 'tsconfig.json' file in your project folder. Which command compiles all TypeScript files according to this config?
Attempts:
2 left
💡 Hint
The '-p' flag specifies the project config file.
✗ Incorrect
The '-p' or '--project' flag tells 'tsc' to use the given config file to compile the project.
🚀 Application
expert2:30remaining
How many JavaScript files are generated after compiling this project?
You have a project with these files: 'app.ts', 'utils.ts', and 'data.ts'. Your 'tsconfig.json' has "outDir": "dist" and "include": ["*.ts"]. After running 'tsc -p tsconfig.json', how many JavaScript files will appear in the 'dist' folder?
Attempts:
2 left
💡 Hint
Each TypeScript file compiles to one JavaScript file unless excluded.
✗ Incorrect
All three '.ts' files are included and compiled, producing three '.js' files in the output folder.