0
0
Typescriptprogramming~10 mins

What survives compilation to JavaScript in Typescript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a variable that will appear in the compiled JavaScript.

Typescript
let [1] = 5;
Drag options to blanks, or click blank then click option'
Anumber
Bcount
Ctype
Dinterface
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a TypeScript type or interface name instead of a variable name.
2fill in blank
medium

Complete the code to declare a function that will be present in the compiled JavaScript.

Typescript
function [1]() { return 10; }
Drag options to blanks, or click blank then click option'
Acalculate
BMyType
CNumber
DIResult
Attempts:
3 left
💡 Hint
Common Mistakes
Using type or interface names as function names.
3fill in blank
hard

Fix the error in the code so that the variable survives compilation.

Typescript
const [1]: string = "hello";
Drag options to blanks, or click blank then click option'
Atype
Bstring
Cgreeting
Dinterface
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a type or interface keyword as variable name.
4fill in blank
hard

Fill both blanks to create a class and method that survive compilation.

Typescript
class [1] {
  [2]() { return 42; }
}
Drag options to blanks, or click blank then click option'
ACalculator
Bcompute
CIResult
Dnumber
Attempts:
3 left
💡 Hint
Common Mistakes
Using type or interface names as class or method names.
5fill in blank
hard

Fill all three blanks to create an object with a property and a method that survive compilation.

Typescript
const obj = {
  [1]: 10,
  [2]() { return this.[3]; }
};
Drag options to blanks, or click blank then click option'
Avalue
BgetValue
Dtype
Attempts:
3 left
💡 Hint
Common Mistakes
Using type names as property or method names.