A lot of people have been tweeting or saying use typescript, learn typescript, since I major in web development. To be honest, I was enticed by this. I also feel the need to state, we should be cautious, to not learn every new and shiny tech out there but I felt this one was going to be useful. There should be a balance in your career path. Learning what is required and what will take you to the next level.
Types in TypeScript
Let's have a quick example
let Element1 = 2;
Element1 has a type that is generated by the value it holds, which is a number, we can also implicitly add the type to a variable.
let Element2: Boolean;
Here the type has been added and when assigning a value to Element2, it has to be Boolean. Also, I'd to say one of the important feature that's in TypeScript is type checking, yes, I've said it earlier but what do I mean by that. If we try to assign, a value of different type to Element 2, we will get an error, sometimes I feel TypeScript is screaming at me, when I do that. Let's take a look.
Element2 = "Hello";
When we do something like this, we're being warned. We get a type error.
Type 'string' is not assignable to type 'boolean'.
-Accepting props -using Interfaces, amongst others.
N.B: I'm still learning all the use case and how to improve my code with TypeScript. My code editor warns me when my ways or method of implementation are wrong :-).
The only way to become better with TypeScript is by practicing. I hope my little note was helpful.