0
0
Typescriptprogramming~20 mins

What types exist only at compile time in Typescript - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
TypeScript Compile-Time Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Types that exist only at compile time in TypeScript
Which of the following types exist only during TypeScript's compile time and do not appear in the generated JavaScript code?
AInterfaces and type aliases
BClasses and enums
CFunctions and variables
DObjects and arrays
Attempts:
2 left
💡 Hint
Think about what TypeScript removes when it compiles to JavaScript.
Predict Output
intermediate
1:30remaining
Output of TypeScript code with interface
What will be the output when this TypeScript code is compiled and run as JavaScript?
Typescript
interface Person {
  name: string;
  age: number;
}

const user: Person = { name: 'Alice', age: 30 };
console.log(user);
A{ name: 'Alice', age: 30 }
Bundefined
CError: Interface Person does not exist at runtime
DReferenceError: user is not defined
Attempts:
2 left
💡 Hint
Interfaces disappear after compilation, but objects remain.
Predict Output
advanced
1:30remaining
Type alias usage and runtime presence
Given this TypeScript code, what will be the output when compiled and run as JavaScript?
Typescript
type ID = number | string;

const userId: ID = 123;
console.log(typeof userId);
ATypeError at runtime
B"ID"
C"string"
D"number"
Attempts:
2 left
💡 Hint
Type aliases do not exist at runtime, only the value does.
🧠 Conceptual
advanced
1:30remaining
Which TypeScript constructs are erased at compile time?
Select the TypeScript constructs that are completely erased and do not exist in the emitted JavaScript code.
AEnums and namespaces
BInterfaces and type aliases
CClasses and functions
DVariables and constants
Attempts:
2 left
💡 Hint
Think about what is used only for type checking.
🧠 Conceptual
expert
2:00remaining
Understanding TypeScript's type system and runtime
Which statement correctly describes the relationship between TypeScript types and JavaScript runtime values?
AInterfaces are converted to JavaScript classes at runtime.
BAll TypeScript types exist at runtime as JavaScript objects.
CTypeScript types are only for compile-time checks and do not exist at runtime.
DType aliases generate JavaScript functions during compilation.
Attempts:
2 left
💡 Hint
Consider what happens to types after TypeScript compiles to JavaScript.