What is the TypeScript Compiler (TSC)?
In the last post we saw an introduction to TypeScript and in this post we are going to see what is the TypeScript Compiler and how this works.
A high level of the flow about Javascript compiler code is this one:
All these steps are done by Javascript runtime that lives in our browser, NodeJs or other Javascript engine
1.- The programmer create a programm.
2.- Then that program is parser by the compiler transform it to a Abstract Syntax tree (AST) in this section all the comments, whitespaces, tabs, spaces are ignored.
3.- Again the compiler convert the AST to a bytecode (we can feed that bytecode into another program called runtime)
4.- Finally the runtime evaluate the codebyte and get us a result.
A high level of the flow about TypeScript compiler code is this one:
All these steps are done by the TSC (TypeScript Compiler)
1.- The programmer create a programm.
In this point (step 1) use our program types.
2.- Then that program is parser by the compiler transform it to a Abstract Syntax tree (AST) in this section all the comments, whitespaces, tabs, spaces are ignored.
In this point (step 2) use our program types.
3.- The code is evaluated by the TypeChecker (special program that verifies that your code is typesafe).
In this point (step 3) use our program types.
4.- Then instead that the compiler convert the AST to bytecode, the AST is compiled to Javascript source.
In this point (step 4) does not use our program types, this means that our program types will never affect our program generated output, and the types are only used for typechecking, so we can update and improve our program types without risking breaking our application.
By Cristina Rojas.