What is TypeScript?
Options
- A faster version of Java made for the browser
- JavaScript with types, compiled down to plain JS (Correct option)
- A CSS preprocessor that adds variables and nesting
- A query language used for relational databases
Answer
JavaScript with added type annotations; it is checked before running and then compiled to plain JavaScript
Why
In JavaScript, a variable can hold anything and mistakes appear only while the program runs.
TypeScript adds types, for example let age: number = 30;. The TypeScript compiler catches mistakes (like using a string where a number is expected) before you run the code.
The result is converted to normal JavaScript, which is what browsers and Node.js run.
Remember
TypeScript = JavaScript + types.