Table of contents
- What is TypeScript?
- How does TypeScript Work?
- Introducing TypeScript Compilers
- Type Checker or Type Resolver
1. What is TypeScript?
2. How does TypeScript Work?
You will notice that TypeScript files come with .ts extension. Once transpiler compiles the .ts files, you will get .js files as output.
3. Introducing TypeScript Compilers
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 a 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.
Type Checker or Type Resolver
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.
Play Anytime with TypeScript
TypeScript Playground is the name of the tool. All that you have to do to click below to access the tool online.
You will be able to share the code segments you create on TypeScript Playground with others. Playground for barista.ts can be accessed here.
Hope you have enjoyed the TypeScript introduction! We have tried to give you an overview of all the goodies that come with the TypeScript.