0
0
Typescriptprogramming~20 mins

TypeScript Compiler Installation and Setup - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
TypeScript Compiler Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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"));
AHello, Alice!
Bgreet("Alice")
CError: name is not defined
Dundefined
Attempts:
2 left
💡 Hint
Think about what the function returns and what console.log prints.
🧠 Conceptual
intermediate
1: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?
Anpm install typescript@latest
Bnpm install -g typescript
Cnpm install --save-dev typescript
Dnpm install typescript
Attempts:
2 left
💡 Hint
Global installation allows using the command in any folder.
🔧 Debug
advanced
2: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);
AReferenceError: count is not defined
BSyntaxError: Unexpected string
CType 'string' is not assignable to type 'number'.
DNo error, compiles successfully
Attempts:
2 left
💡 Hint
Check the type assigned to 'count' and the declared type.
📝 Syntax
advanced
1: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?
Atsc -p tsconfig.json
Btsc --project tsconfig.json
Ctsc --config tsconfig.json
Dtsc --all
Attempts:
2 left
💡 Hint
The '-p' flag specifies the project config file.
🚀 Application
expert
2: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?
A3
B0
C1
DDepends on the content of the files
Attempts:
2 left
💡 Hint
Each TypeScript file compiles to one JavaScript file unless excluded.