You will notice that TypeScript files come with .ts extension. Once transpiler compiles the .ts files, you will get .js files as output.
The compiler will throw compile errors to notify of the same. You can correct all those errors before you actually execute the code. It is an extremely important service. If you have ever worked with codes you would know that edge cases and logic errors can result in the crash of our application during runtime.
Thanks to TypeScript, we will be using the type definitions in a consistent manner throughout the code.
The compiler constitutes of various parts which assist in the fast processing of the source code. And these parts help make the code predictable.
A parser is an extremely crucial and complex component. Parser builds a data structure from the TypeScript source files and input data. And the data structure is referred to as an Abstract Syntax Tree here. The parser comes up with a structural form of the source code. It is helpful in analyzing whether we are following the grammar of the language or not. The parser checks the source code to see if it is following the correct syntax or not.
Let’s examine the working of the binder with an example. Let’s assume that we have a module and a function with the same name. With the help of a Symbol, the binder links these named declarations. It helps the type system to instill some meaning into it.
This component generates type diagnostics, checks semantic operations and assigns types for each construct.
Pre-processor manages and resolves references amongst files. It accomplishes its goals with the help of ///<reference path=…/> or import.
You will be able to share the code segments you create on TypeScript Playground with others. Playground for barista.ts can be accessed here.
It's social media for devs
Level up every day