Learn Angular for Back-End Developer (Part 2) -TypeScript Fundamentals
An easy guide to learn TypeScript quickly to be comfortable with Angular applications
--
Back-End developers are familiar with type-safe Object-Oriented language like C# or Java, but JavaScript, the most popular client-side language is a scripting language and this is the biggest challenge for back end developers.
Fortunately, Angular framework uses a superset of JavaScript called TypeScript, which is an Object-Oriented Programming language, it simplifies JavaScript code and makes it easier to read and debug.
This article is the continuation of the first one already published here:
In this article, I’m going to introduce the fundamentals of TypeScript in order to be comfortable with Angular framework.
What is Typescript ?
As I said in the introduction, TypeScript is a superset of JavaScript, any valid JavaScript code is also a valid TypeScript code. However, TypeScript has additional features known as Static typing, Object-Oriented concepts like Interfaces, Classes, Constructors, Access modifiers and compile-time errors. In addition, TypeScript provides tools like IntelliSense and parameter info.
Most browsers don’t understand TypeScript, so we need a compiler that can compile or more precisely transpile TypeScript code to JavaScript code that browsers can understand.
When we build an Angular app, Angular CLI calls TypeScript compiler under the hood to transpile all the TypeScript code.
To install TypeScript compiler independently of Angular, open a terminal window and run the following command:
npm install -g typescript
To check the TypeScript version run the following command:
tsc --version
To compile TypeScript file, run the following command: