What is TypeScript?
What is TypeScript? π§ β£ β£ β£
β β β β β β β β β β£
is the typed version of JavaScript, built by Microsoft, compiles down to JavaScript, and tends to be less error-prone. β£ β£
β β β β β β β β β β£ β£
π€―What are the advantages of TypeScript? β£ β£
β β β β β β β β β β£ β£
The fact that it catches the errors in your code which leads to understanding your code better and makes it less error-prone, easily sets TS as one of my favorites. β£ β£
β β β β β β β β β β£ β£
ππΌIf you see JavaScript like this: β£ β£
β β β β β β β β β β£ β£
export const Count = (value) =>{...}; β£ β£ β£ β£
β β β β β β β β β β£
You can write it on TypeScript like this:ππΌππΌππΌ β£ β£ β£
export const Count = (value: number) =>{...}; β£ β£
β β β β β β β β β β£ β£
As you can see we just defined the type of our parameter, we're saying the "value" parameter should be a number and if it's not a number... our code will get an error... Woah!! I mean, that's amazing, it's like having a friend give you a hint that you may not understand your code but TS does! β£ β£ β£ β£
β β β β β β β β β β£
How to declare the syntax? π€ β£ β£
β β β β β β β β β β£ β£
Write the name of the variable followed by: and the type like this and then followed by = and the value of the variable: β£ β£ β£
β β β β β β β β β β£ β£
let myVar: string = "hi"; β£ β£ β£
π¬ Have you ever used TypeScript? Shared your thoughts below ππΌππΌ β£