Angular - The Ultimate Walkthrough Learning Guide
What do you need to learn to become an Angular Master? The journey can feel overwhelming. The YouTube series can feel like it’s only covering the basics. That’s why I’ve created this Walkthrough Learning Guide to help you get started on your Angular journey. From zero to pro, these articles

TypeScript. There are a lot of people out there who look at it with derision when they hear that a framework, library or bits of code has been written in. Some people even go as far to avoid using it simply because they view it as another thing to learn.

However, TypeScript is one of the best things to come out of Microsoft that is completely free, opensource and widely accepted by the community. the Angular team liked it so much that they even built their CLI generators around it.

Here’s the low down on why TypeScript is actually rather awesome.

Turns JavaScript into a grown up language

If we go back to the 90s when everything was just coming out, JavaScript entered the scene as snowflake effects for web pages. I was there. I remember. Fast forward a decade and a half, it is now running backends with RESTful APIs, mobile web apps and entire frontends.

While ECMA is pushing for yearly updates of the language, there is still quite a bit of room for JavaScript to grow up and learn from other languages such as Java and C#.

With TypeScript, it gives JavaScript developers the ability to strongly type their code and create resistance against code fragility. This can help reduce errors due to incorrect data types, in addition to other things like class declaration which was not introduced to JavaScript until ES6.

Why we need types in JavaScript

On the surface, TypeScript looks like any ordinary JavaScript code with the addition of typed data. The handiness of typing is that it prevents accidental or incorrect usage of the data given. It gives the loosely typed language a more strict approach to coding.

With TypeScript, a block of code may look like this:

 let cat: string = "Merlin";
 let age: number = 3;
 
function increaseAge( age: number ){ 
     return age + 1; 
}

As trivial as it may seem, with TypeScript, if you were to run increaseAge(cat), TypeScript will throw an error because the function increaseAge() is expecting a number and not a string. However, if that were to run under plain JavaScript, increaseAge(cat) return Merlin1 instead of telling us that something went wrong. This could create errors further down the line and we’ll need to bust out our bug tracing skills and figure out what went wrong.

The above works exactly the same way as JavaScript but with a little bit of syntax sugar to help us detect potential errors before it happens.

This post is for paying subscribers only

Sign up now and upgrade your account to read the post and get access to the full library of posts for paying subscribers only.

Sign up now Already have an account? Sign in