Typescript Fundamentals

In order to build applications with angular you need to be comfortable with typescript.

So in this section I’m going to introduce you to the fundamentals of typescript an object oriented programming principles
So by the end of this section you will have a good understanding of type annotations Arrow functions interfaces classes instructors access modifiers properties and modules.

So, what is TypeScript?

TypeScript, is not an entirely new language, it’s a super set of JavaScript, so that means any valid JavaScript code is also valid TypeScript code, but TypeScript has additional features that do not exist in the current version of JavaScript supported by most browsers out there.

in TypeScript we have this concept of strong or static typing if you have worked with languages like C# and Java, you will know that in these languages, when we define the variable, we need to specify the type of that variable. Now, in TypeScript, typing is optional, so we don’t have to use this feature. But using this feature, makes our applications more predictable, and it also makes it easier to debug them when something goes wrong. TypeScript also brings quite a few object oriented features that we have missed in JavaScript for a long time. We have the concept of Classes, Interfaces, Constructors, Access Modifiers, like public and private, Fills, Properties, Generics and so on. You’re going to learn about this in this section.

Now, another benefit of using TypeScript is that with TypeScript we catch errors at Compile-time, instead of Run-time, but of course not all kinds of errors, but a lot of errors. So there is a compilation step involved, and when we compile our TypeScript code, we can catch these errors and fix them before deploying our application. And finally, another benefit of using TypeScript, is that we get access to some great tools out there. One thing I personally love about TypeScript is the intelligence that we get in our code editors.

Again you’re going to see that in this section. So TypeScript is a beautiful language and it’s basically a superset of JavaScript, so any valid JavaScript code is also valid TypeScript code. Now, the browsers out there, they don’t understand TypeScript, and it’s very unlikely that they’re going to support it in the future, so we need to compile for more accurately, so we Transpile our TypeScript code, into JavaScript.

So, this is part of building our application, whenever we build our application, TypeScript compiler kicks in, and it Transpiles our TypeScript code into JavaScript code our browsers can understand.

Now, that’s enough introduction. Next I’m going to show you how to install TypeScript, and write your first TypeScript program.

by kushan