0
0
Typescriptprogramming~5 mins

What types exist only at compile time in Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What are types that exist only at compile time in TypeScript?
These are types used by the TypeScript compiler to check code correctness but do not exist in the JavaScript output. They help catch errors before running the code.
Click to reveal answer
beginner
Do TypeScript interfaces exist in the compiled JavaScript code?
No, interfaces are removed during compilation. They only help with type checking while writing code and do not produce any JavaScript code.
Click to reveal answer
beginner
What happens to TypeScript type aliases after compilation?
Type aliases are used only at compile time for type checking and are erased in the compiled JavaScript, so they do not exist at runtime.
Click to reveal answer
intermediate
Are enums in TypeScript compile-time only types?
No, enums generate JavaScript code and exist at runtime. Only types, interfaces, and generics are compile-time only.
Click to reveal answer
intermediate
What is the difference between types/interfaces and classes in TypeScript regarding runtime?
Types and interfaces exist only at compile time and are erased after compilation. Classes produce JavaScript code and exist at runtime.
Click to reveal answer
Which TypeScript construct exists only at compile time?
AClass
BEnum
CInterface
DFunction
What happens to type aliases after TypeScript compilation?
AThey are removed and do not exist at runtime
BThey become JavaScript variables
CThey become functions
DThey become classes
Which of these exists at runtime in JavaScript after compiling TypeScript?
AType alias
BEnum
CInterface
DType parameter
Are TypeScript generics present in the compiled JavaScript code?
AYes, as functions
BYes, as objects
CYes, as classes
DNo, they are compile-time only
Which statement is true about TypeScript interfaces?
AThey exist only at compile time
BThey become JavaScript objects
CThey compile to JavaScript classes
DThey are runtime types
Explain which TypeScript types exist only at compile time and why.
Think about what TypeScript removes when it creates JavaScript.
You got /5 concepts.
    Describe the difference between TypeScript types/interfaces and classes regarding runtime presence.
    Consider what code actually runs in the browser or Node.js.
    You got /4 concepts.