In this article we are going to learn about Angular, the role of TypeScript in Angular Applications, and how an Angular compiler works. So, let’s start with the first understanding of Angular.
What is Angular?
An angular framework is built entirely in TypeScript, and as a result, using TypeScript with Angular provides a seamless experience. TypeScript is a primary language for Angular application development. So, an understanding of TypeScript is also necessary to develop Angular applications. So, now we let’s move on to discuss some details of TypeScript.
let val:number = 123; // In TypeScript (TS) val = 'abc' // In TS this line will cause an error
Advantages of TypeScript:
Looking to Hire Angular Development Team?
Share the details of your request and we will provide you with a full-cycle team under one roof.
Why do we need Angular?
-Gives our applications a clean structure that is easy to understand and maintain.
-Includes a lot of re-usable code.
-Makes our applications more testable so it will make your life easier.
The Angular compiler is the tool used to compile Angular applications and libraries. The compiler is built on the TypeScript compiler and extends the process of compiling TypeScript code to add additional code generation related to Angular’s capabilities.
In this way, the Angular compiler can be considered as an extended TypeScript compiler that also knows how to “execute” Angular decorators, applying their effects to the decorated classes at build time (as opposed to run time).
In the Angular project, this compilation is handled by the Angular CLI. The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications directly from a command shell. This is one of the reasons why we need a project management tool like the CLI. This is the recommended and the best way of creating Angular projects because there are a couple of files that need to be converted before they can run in the browser and the CLI does all of that and it also heavily optimizes our code so that we ship a highly optimized code version to the browser once we finally deploy our app. The Angular CLI can be installed using the below command:
npm install -g @angular/cli
Furthermore, Node.js needs to be installed before this. It’s a server-side language and it will be used behind the scenes by the CLI to bundle and optimize our project. We’ll use Node Package manager to manage the different dependencies an Angular project has. Dependencies are things like the Angular framework itself but also some other libraries that the framework uses. The important goals of the Angular compiler are listed below:
-Apply TypeScript’s type-checking rules to component templates.
-Compile Angular decorators, including components and their templates.
-Re-compile quickly when the developer makes a change.
So, in this article, we learned briefly about Angular, the role of TypeScript in Angular applications, and what happens during the compilation phase of our Angular application. To learn more about how to write code in Angular, the official documentation tutorial can be followed on this link: https://angular.io/start where there is a step-by-step guide to building a project in Angular.