Q01. What is TypeScript, and how does it relate to JavaScript?

TypeScript is a statically checked superset of JavaScript that adds a type system and compile-time tooling. It is typically transformed into JavaScript for execution. Its types are erased, so runtime validation must be implemented separately for untrusted values.

TypeScript source is checked and transformed; JavaScript runs in the runtime. Types improve static correctness but do not add automatic runtime validation.

Note

Interview approach: define the concept, explain why it matters, then mention one trade-off or limitation.

TypeScript compilation
const greeting: string = "Hello";
console.log(greeting);
💡 The type annotation is removed from emitted JavaScript; the runtime executes the string value.
Key Takeaways
  • Explain the concept in your own words.
  • Know the practical trade-off and its limits.
  • Use a small example to demonstrate the idea.
Knowledge Check

Which language normally executes in a browser after standard TypeScript compilation?