DAY 0 OF 30
What TypeScript actually is
TypeScript is a superset of JavaScript. It takes the JavaScript language and adds a type system on top: a way of stating what kind of value every variable, parameter and return holds.
You cannot run TypeScript directly. It goes through the TypeScript compiler, which checks your types, reads them, and reports a type error anywhere the values do not match.
Build time is when the compiler runs. It checks for type errors and reports them. It then removes all types, turning your TypeScript into plain JavaScript.
Runtime is the point at which your program is plain JavaScript and runs like a normal JavaScript program.
Static typing means types are checked before the code runs. TypeScript is statically typed because the compiler does its checking at build time.
Check yourself
It is not a separate language. It compiles down to JavaScript.
It checks your types and reports any type errors, then removes all the types and outputs plain JavaScript.
Did you say:
- ✓checks types
- ✓reports type errors
- ✓removes types
- ✓outputs plain JavaScript
Statically typed. The compiler checks the types at build time, before the code runs.
Did you say:
- ✓statically typed
- ✓checked at build time
- ✓before the code runs