Make Mobile Apps with Ionic Framework 3 - Tutorial Part 2 #What is TypeScript
In order to build applications with Angular, you need to be comfortable with TypeScript. So in this article I'm going to introduce you to the fundamentals of TypeScript and object oriented programming principles. So now let's get started.
What is TypeScript?
Typescript is not an entirely new language. It's a superset 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.
For example in TypeScript we had this concept of strong or static typing. If you have worked with languages like C# or Java you know that in these languages when we define a variable we need to specify the type of that variable.
The 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 to concept of classes, interfaces, constructors, access modifiers like public and private, fields, properties, generics and so on.
Another benefit of using TypeScript catch errors at compile time instead of at runtime well of course not all kinds of errors but a lot of errors. So there is a compilation step involved and when we complete our TypeScript code we can catch this errors and fix them before deploying our application.
So TypeScript is a beautiful language and is basically a superset of Javascript for any valid Javascript code is also valid TypeScript code. Now the browsers out there didn't understand typescript. And it's very unlikely that they're going to support it in the future. So we need to compile or more accurately transpile are TypeScript code into Javascript. So this is part of a building our application.
Whenever we build our application, TypeScript compiler kicks in. And it transpiles are TypeScript code into Javascript code that browsers can understand.
Now that's enough introduction. Next post about installing Typescript and writing about our first Typescript program.